sourcegit/src/Commands/Fetch.cs

45 lines
1.3 KiB
C#
Raw Normal View History

using System;
2021-04-29 05:05:55 -07:00
namespace SourceGit.Commands
{
public class Fetch : Command
{
public Fetch(string repo, string remote, bool prune, bool noTags, Action<string> outputHandler)
{
_outputHandler = outputHandler;
WorkingDirectory = repo;
Context = repo;
2021-04-29 05:05:55 -07:00
TraitErrorAsOutput = true;
2024-07-09 03:13:15 -07:00
SSHKey = new Config(repo).Get($"remote.{remote}.sshkey");
Args = "fetch --progress --verbose ";
if (prune)
Args += "--prune ";
if (noTags)
Args += "--no-tags ";
else
Args += "--force ";
2021-04-29 05:05:55 -07:00
Args += remote;
}
public Fetch(string repo, string remote, string localBranch, string remoteBranch, Action<string> outputHandler)
{
_outputHandler = outputHandler;
WorkingDirectory = repo;
Context = repo;
TraitErrorAsOutput = true;
2024-07-09 03:13:15 -07:00
SSHKey = new Config(repo).Get($"remote.{remote}.sshkey");
Args = $"fetch --progress --verbose {remote} {remoteBranch}:{localBranch}";
}
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
}
}