-
Notifications
You must be signed in to change notification settings - Fork 204
/
Copy pathQueryTrackStatus.cs
34 lines (29 loc) · 921 Bytes
/
QueryTrackStatus.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
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;
}
}
}