sourcegit/src/Commands/Clone.cs

32 lines
1,009 B
C#
Raw Normal View History

using System;
2021-04-29 05:05:55 -07:00
namespace SourceGit.Commands {
public class Clone : Command {
private Action<string> _notifyProgress;
2021-04-29 05:05:55 -07:00
public Clone(string ctx, string path, string url, string localName, string sshKey, string extraArgs, Action<string> ouputHandler) {
Context = ctx;
WorkingDirectory = path;
2021-04-29 05:05:55 -07:00
TraitErrorAsOutput = true;
if (string.IsNullOrEmpty(sshKey)) {
Args = "-c credential.helper=manager ";
} else {
Args = $"-c core.sshCommand=\"ssh -i '{sshKey}'\" ";
}
Args += "clone --progress --verbose --recurse-submodules ";
2021-04-29 05:05:55 -07:00
if (!string.IsNullOrEmpty(extraArgs)) Args += $"{extraArgs} ";
Args += $"{url} ";
if (!string.IsNullOrEmpty(localName)) Args += localName;
_notifyProgress = ouputHandler;
2021-04-29 05:05:55 -07:00
}
protected override void OnReadline(string line) {
_notifyProgress?.Invoke(line);
}
2021-04-29 05:05:55 -07:00
}
}