2024-07-18 18:29:16 -07:00
|
|
|
|
using System;
|
|
|
|
|
|
|
|
|
|
namespace SourceGit.Commands
|
|
|
|
|
{
|
|
|
|
|
public class QueryTrackStatus : Command
|
|
|
|
|
{
|
2024-07-22 22:58:57 -07:00
|
|
|
|
public QueryTrackStatus(string repo, string local, string upstream)
|
2024-07-18 18:29:16 -07:00
|
|
|
|
{
|
|
|
|
|
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;
|
|
|
|
|
|
2024-07-24 04:07:31 -07:00
|
|
|
|
var lines = rs.StdOut.Split(new char[] { '\n', '\r' }, StringSplitOptions.RemoveEmptyEntries);
|
2024-07-18 18:29:16 -07:00
|
|
|
|
foreach (var line in lines)
|
|
|
|
|
{
|
|
|
|
|
if (line[0] == '>')
|
|
|
|
|
status.Behind.Add(line.Substring(1));
|
|
|
|
|
else
|
|
|
|
|
status.Ahead.Add(line.Substring(1));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return status;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|