mirror of
https://github.com/sourcegit-scm/sourcegit
synced 2025-05-23 05:05:00 +00:00
feature: supports searching revision files (#775)
This commit is contained in:
parent
536f225867
commit
894f3e9b03
10 changed files with 350 additions and 15 deletions
|
@ -1,19 +1,19 @@
|
|||
namespace SourceGit.Commands
|
||||
{
|
||||
public class QueryCurrentRevisionFiles : Command
|
||||
public class QueryRevisionFileNames : Command
|
||||
{
|
||||
public QueryCurrentRevisionFiles(string repo)
|
||||
public QueryRevisionFileNames(string repo, string revision)
|
||||
{
|
||||
WorkingDirectory = repo;
|
||||
Context = repo;
|
||||
Args = "ls-tree -r --name-only HEAD";
|
||||
Args = $"ls-tree -r -z --name-only {revision}";
|
||||
}
|
||||
|
||||
public string[] Result()
|
||||
{
|
||||
var rs = ReadToEnd();
|
||||
if (rs.IsSuccess)
|
||||
return rs.StdOut.Split('\n', System.StringSplitOptions.RemoveEmptyEntries);
|
||||
return rs.StdOut.Split('\0', System.StringSplitOptions.RemoveEmptyEntries);
|
||||
|
||||
return [];
|
||||
}
|
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue