mirror of
https://github.com/sourcegit-scm/sourcegit
synced 2025-05-22 04:34:59 +00:00

- Use new syntex `[...]` instead of `new char[] {...}` to create char arrays - Use `string.ReplaceLineEndings('\n').Split('\n')` instead of `string.Split(['\n', '\r'], StringSplitOptions.RemoveEmptyEntries)` because that the `Signer` part may be missing Signed-off-by: leo <longshuang@msn.cn>
34 lines
921 B
C#
34 lines
921 B
C#
using System;
|
|
|
|
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 Models.BranchTrackStatus Result()
|
|
{
|
|
var status = new Models.BranchTrackStatus();
|
|
|
|
var rs = ReadToEnd();
|
|
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;
|
|
}
|
|
}
|
|
}
|