feature: supports searching revision files (#775)

This commit is contained in:
leo 2024-12-02 21:44:15 +08:00
parent 536f225867
commit 894f3e9b03
No known key found for this signature in database
10 changed files with 350 additions and 15 deletions

View file

@ -12,7 +12,7 @@ namespace SourceGit.Commands
{
WorkingDirectory = repo;
Context = repo;
Args = $"ls-tree {sha}";
Args = $"ls-tree -z {sha}";
if (!string.IsNullOrEmpty(parentFolder))
Args += $" -- \"{parentFolder}\"";
@ -20,11 +20,27 @@ namespace SourceGit.Commands
public List<Models.Object> Result()
{
Exec();
var rs = ReadToEnd();
if (rs.IsSuccess)
{
var start = 0;
var end = rs.StdOut.IndexOf('\0', start);
while (end > 0)
{
var line = rs.StdOut.Substring(start, end - start);
Parse(line);
start = end + 1;
end = rs.StdOut.IndexOf('\0', start);
}
if (start < rs.StdOut.Length)
Parse(rs.StdOut.Substring(start));
}
return _objects;
}
protected override void OnReadline(string line)
private void Parse(string line)
{
var match = REG_FORMAT().Match(line);
if (!match.Success)