mirror of
https://github.com/sourcegit-scm/sourcegit
synced 2025-05-21 20:24:59 +00:00
feature: add children list to the commit base info view (#673)
This commit is contained in:
parent
e2e79fe1b3
commit
03f96cc9f8
7 changed files with 88 additions and 7 deletions
34
src/Commands/QueryCommitChildren.cs
Normal file
34
src/Commands/QueryCommitChildren.cs
Normal file
|
@ -0,0 +1,34 @@
|
|||
namespace SourceGit.Commands
|
||||
{
|
||||
public class QueryCommitChildren : Command
|
||||
{
|
||||
public QueryCommitChildren(string repo, string sha)
|
||||
{
|
||||
WorkingDirectory = repo;
|
||||
Context = repo;
|
||||
_sha = sha;
|
||||
Args = $"rev-list --children --all {sha}^..";
|
||||
}
|
||||
|
||||
public string[] Result()
|
||||
{
|
||||
var rs = ReadToEnd();
|
||||
if (!rs.IsSuccess)
|
||||
return [];
|
||||
|
||||
int start = rs.StdOut.IndexOf($"\n{_sha}");
|
||||
if (start != -1)
|
||||
{
|
||||
int end = rs.StdOut.IndexOf('\n', start + 1);
|
||||
if (end == -1)
|
||||
end = rs.StdOut.Length;
|
||||
start = rs.StdOut.IndexOf(' ', start);
|
||||
if (start != -1 && start < end)
|
||||
return rs.StdOut.Substring(start + 1, end - start - 1).Split(' ', System.StringSplitOptions.RemoveEmptyEntries);
|
||||
}
|
||||
return [];
|
||||
}
|
||||
|
||||
private string _sha;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue