2024-08-23 01:52:55 -07:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
|
|
|
|
namespace SourceGit.Commands
|
|
|
|
|
{
|
|
|
|
|
public class QueryRefsContainsCommit : Command
|
|
|
|
|
{
|
2024-08-23 07:26:17 -07:00
|
|
|
|
public QueryRefsContainsCommit(string repo, string commit)
|
2024-08-23 01:52:55 -07:00
|
|
|
|
{
|
|
|
|
|
WorkingDirectory = repo;
|
|
|
|
|
RaiseError = false;
|
|
|
|
|
Args = $"for-each-ref --format=\"%(refname)\" --contains {commit}";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public List<Models.Decorator> Result()
|
|
|
|
|
{
|
|
|
|
|
var rs = new List<Models.Decorator>();
|
|
|
|
|
|
|
|
|
|
var output = ReadToEnd();
|
|
|
|
|
if (!output.IsSuccess)
|
|
|
|
|
return rs;
|
|
|
|
|
|
|
|
|
|
var lines = output.StdOut.Split('\n');
|
|
|
|
|
foreach (var line in lines)
|
|
|
|
|
{
|
|
|
|
|
if (line.StartsWith("refs/heads/", StringComparison.Ordinal))
|
|
|
|
|
rs.Add(new() { Name = line.Substring("refs/heads/".Length), Type = Models.DecoratorType.LocalBranchHead });
|
|
|
|
|
else if (line.StartsWith("refs/remotes/", StringComparison.Ordinal))
|
|
|
|
|
rs.Add(new() { Name = line.Substring("refs/remotes/".Length), Type = Models.DecoratorType.RemoteBranchHead });
|
|
|
|
|
else if (line.StartsWith("refs/tags/", StringComparison.Ordinal))
|
|
|
|
|
rs.Add(new() { Name = line.Substring("refs/tags/".Length), Type = Models.DecoratorType.Tag });
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return rs;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|