refactor<*>: rewrite all with AvaloniaUI

This commit is contained in:
leo 2024-02-06 15:08:37 +08:00
parent 0136904612
commit 2a62596999
521 changed files with 19780 additions and 23244 deletions

View file

@ -1,24 +1,18 @@
using System;
using System;
namespace SourceGit.Commands {
/// <summary>
/// 克隆
/// </summary>
public class Clone : Command {
private Action<string> handler = null;
private Action<string> onError = null;
private Action<string> _notifyProgress;
public Clone(string path, string url, string localName, string sshKey, string extraArgs, Action<string> outputHandler, Action<string> errHandler) {
Cwd = path;
public Clone(string ctx, string path, string url, string localName, string sshKey, string extraArgs, Action<string> ouputHandler) {
Context = ctx;
WorkingDirectory = path;
TraitErrorAsOutput = true;
handler = outputHandler;
onError = errHandler;
if (string.IsNullOrEmpty(sshKey)) {
Args = $"-c core.sshCommand=\"ssh -i '{sshKey}'\" ";
} else {
Args = "-c credential.helper=manager ";
} else {
Args = $"-c core.sshCommand=\"ssh -i '{sshKey}'\" ";
}
Args += "clone --progress --verbose --recurse-submodules ";
@ -26,14 +20,12 @@ namespace SourceGit.Commands {
if (!string.IsNullOrEmpty(extraArgs)) Args += $"{extraArgs} ";
Args += $"{url} ";
if (!string.IsNullOrEmpty(localName)) Args += localName;
_notifyProgress = ouputHandler;
}
public override void OnReadline(string line) {
handler?.Invoke(line);
}
public override void OnException(string message) {
onError?.Invoke(message);
protected override void OnReadline(string line) {
_notifyProgress?.Invoke(line);
}
}
}