sourcegit/src/Commands/Pull.cs

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

using System;
2021-04-29 05:05:55 -07:00
namespace SourceGit.Commands
{
public class Pull : Command
{
public Pull(string repo, string remote, string branch, bool useRebase, bool noTags, Action<string> outputHandler)
{
_outputHandler = outputHandler;
WorkingDirectory = repo;
Context = repo;
2021-04-29 05:05:55 -07:00
TraitErrorAsOutput = true;
var sshKey = new Config(repo).Get($"remote.{remote}.sshkey");
if (string.IsNullOrEmpty(sshKey))
Args = "-c credential.helper=manager ";
else
UseSSHKey(sshKey);
Args += "pull --verbose --progress --tags ";
if (useRebase)
Args += "--rebase ";
if (noTags)
Args += "--no-tags ";
2021-04-29 05:05:55 -07:00
Args += $"{remote} {branch}";
}
protected override void OnReadline(string line)
{
_outputHandler?.Invoke(line);
2021-04-29 05:05:55 -07:00
}
private readonly Action<string> _outputHandler;
2021-04-29 05:05:55 -07:00
}
}