Files
sourcegit/src/Commands/Fetch.cs
leo 40765826ce code_review: PR #1492
- 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>
2025-07-03 17:30:06 +08:00

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;
}
}