mirror of
https://fastgit.cc/github.com/sourcegit-scm/sourcegit
synced 2026-04-24 19:02:39 +08:00
- Remove all synchronous method in commands - `Command.ReadToEndAsync` now is protected method - Rename `ResultAsync` to `GetResultAsync` - Call `ConfigureAwait(false)` when there's no context Signed-off-by: leo <longshuang@msn.cn>
45 lines
1.1 KiB
C#
45 lines
1.1 KiB
C#
using System.Threading.Tasks;
|
|
|
|
namespace SourceGit.Commands
|
|
{
|
|
public class Fetch : Command
|
|
{
|
|
public Fetch(string repo, string remote, bool noTags, bool force)
|
|
{
|
|
_remoteKey = $"remote.{remote}.sshkey";
|
|
|
|
WorkingDirectory = repo;
|
|
Context = repo;
|
|
Args = "fetch --progress --verbose ";
|
|
|
|
if (noTags)
|
|
Args += "--no-tags ";
|
|
else
|
|
Args += "--tags ";
|
|
|
|
if (force)
|
|
Args += "--force ";
|
|
|
|
Args += remote;
|
|
|
|
}
|
|
|
|
public Fetch(string repo, Models.Branch local, Models.Branch remote)
|
|
{
|
|
_remoteKey = $"remote.{remote.Remote}.sshkey";
|
|
|
|
WorkingDirectory = repo;
|
|
Context = repo;
|
|
Args = $"fetch --progress --verbose {remote.Remote} {remote.Name}:{local.Name}";
|
|
}
|
|
|
|
public async Task<bool> RunAsync()
|
|
{
|
|
SSHKey = await new Config(WorkingDirectory).GetAsync(_remoteKey).ConfigureAwait(false);
|
|
return await ExecAsync().ConfigureAwait(false);
|
|
}
|
|
|
|
private readonly string _remoteKey;
|
|
}
|
|
}
|