mirror of
https://github.com/sourcegit-scm/sourcegit.git
synced 2024-12-27 21:27:19 -08:00
153a1f30b2
* Background auto fetch will always disable this option * This option is not add to pull operation Signed-off-by: leo <longshuang@msn.cn>
47 lines
1.4 KiB
C#
47 lines
1.4 KiB
C#
using System;
|
|
|
|
namespace SourceGit.Commands
|
|
{
|
|
public class Fetch : Command
|
|
{
|
|
public Fetch(string repo, string remote, bool noTags, bool prune, bool force, Action<string> outputHandler)
|
|
{
|
|
_outputHandler = outputHandler;
|
|
WorkingDirectory = repo;
|
|
Context = repo;
|
|
TraitErrorAsOutput = true;
|
|
SSHKey = new Config(repo).Get($"remote.{remote}.sshkey");
|
|
Args = "fetch --progress --verbose ";
|
|
|
|
if (noTags)
|
|
Args += "--no-tags ";
|
|
else
|
|
Args += "--tags ";
|
|
|
|
if (force)
|
|
Args += "--force ";
|
|
|
|
if (prune)
|
|
Args += "--prune ";
|
|
|
|
Args += remote;
|
|
}
|
|
|
|
public Fetch(string repo, Models.Branch local, Models.Branch remote, Action<string> outputHandler)
|
|
{
|
|
_outputHandler = outputHandler;
|
|
WorkingDirectory = repo;
|
|
Context = repo;
|
|
TraitErrorAsOutput = true;
|
|
SSHKey = new Config(repo).Get($"remote.{remote.Remote}.sshkey");
|
|
Args = $"fetch --progress --verbose {remote.Remote} {remote.Name}:{local.Name}";
|
|
}
|
|
|
|
protected override void OnReadline(string line)
|
|
{
|
|
_outputHandler?.Invoke(line);
|
|
}
|
|
|
|
private readonly Action<string> _outputHandler;
|
|
}
|
|
}
|