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>
36 lines
1004 B
C#
36 lines
1004 B
C#
using System;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace SourceGit.Commands
|
|
{
|
|
public class QueryTrackStatus : Command
|
|
{
|
|
public QueryTrackStatus(string repo, string local, string upstream)
|
|
{
|
|
WorkingDirectory = repo;
|
|
Context = repo;
|
|
Args = $"rev-list --left-right {local}...{upstream}";
|
|
}
|
|
|
|
public async Task<Models.BranchTrackStatus> GetResultAsync()
|
|
{
|
|
var status = new Models.BranchTrackStatus();
|
|
|
|
var rs = await ReadToEndAsync().ConfigureAwait(false);
|
|
if (!rs.IsSuccess)
|
|
return status;
|
|
|
|
var lines = rs.StdOut.Split(['\r', '\n'], StringSplitOptions.RemoveEmptyEntries);
|
|
foreach (var line in lines)
|
|
{
|
|
if (line[0] == '>')
|
|
status.Behind.Add(line.Substring(1));
|
|
else
|
|
status.Ahead.Add(line.Substring(1));
|
|
}
|
|
|
|
return status;
|
|
}
|
|
}
|
|
}
|