sourcegit/src/Commands/Clone.cs

37 lines
1,016 B
C#
Raw Normal View History

using System;
2021-04-29 05:05:55 -07:00
namespace SourceGit.Commands
{
public class Clone : Command
{
private readonly 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
UseSSHKey(sshKey);
Args += "clone --progress --verbose --recurse-submodules ";
if (!string.IsNullOrEmpty(extraArgs))
Args += $"{extraArgs} ";
2021-04-29 05:05:55 -07:00
Args += $"{url} ";
if (!string.IsNullOrEmpty(localName))
Args += localName;
2021-04-29 05:05:55 -07:00
_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
}
}