2024-02-05 23:08:37 -08:00
|
|
|
|
using System;
|
2021-04-29 05:05:55 -07:00
|
|
|
|
|
2024-03-17 18:37:06 -07:00
|
|
|
|
namespace SourceGit.Commands
|
|
|
|
|
{
|
|
|
|
|
public class Pull : Command
|
|
|
|
|
{
|
2024-07-01 01:19:08 -07:00
|
|
|
|
public Pull(string repo, string remote, string branch, bool useRebase, bool noTags, Action<string> outputHandler)
|
2024-03-17 18:37:06 -07:00
|
|
|
|
{
|
2024-02-05 23:08:37 -08:00
|
|
|
|
_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 = "pull --verbose --progress --tags ";
|
2021-04-29 05:05:55 -07:00
|
|
|
|
|
2024-03-31 01:54:29 -07:00
|
|
|
|
if (useRebase)
|
|
|
|
|
Args += "--rebase ";
|
2024-07-01 01:19:08 -07:00
|
|
|
|
if (noTags)
|
|
|
|
|
Args += "--no-tags ";
|
|
|
|
|
|
2021-04-29 05:05:55 -07:00
|
|
|
|
Args += $"{remote} {branch}";
|
|
|
|
|
}
|
|
|
|
|
|
2024-03-17 18:37:06 -07:00
|
|
|
|
protected override void OnReadline(string line)
|
|
|
|
|
{
|
2024-02-05 23:08:37 -08:00
|
|
|
|
_outputHandler?.Invoke(line);
|
2021-04-29 05:05:55 -07:00
|
|
|
|
}
|
|
|
|
|
|
2024-03-17 18:37:06 -07:00
|
|
|
|
private readonly Action<string> _outputHandler;
|
2021-04-29 05:05:55 -07:00
|
|
|
|
}
|
2024-03-31 01:54:29 -07:00
|
|
|
|
}
|