mirror of
https://github.com/sourcegit-scm/sourcegit
synced 2025-05-24 05:35:00 +00:00
refactor: re-write commit searching (part 3)
Signed-off-by: leo <longshuang@msn.cn>
This commit is contained in:
parent
ee7ccc0391
commit
bb2284c4c9
3 changed files with 15 additions and 18 deletions
|
@ -1,4 +1,6 @@
|
||||||
namespace SourceGit.Commands
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace SourceGit.Commands
|
||||||
{
|
{
|
||||||
public class QueryRevisionFileNames : Command
|
public class QueryRevisionFileNames : Command
|
||||||
{
|
{
|
||||||
|
@ -9,13 +11,17 @@
|
||||||
Args = $"ls-tree -r -z --name-only {revision}";
|
Args = $"ls-tree -r -z --name-only {revision}";
|
||||||
}
|
}
|
||||||
|
|
||||||
public string[] Result()
|
public List<string> Result()
|
||||||
{
|
{
|
||||||
var rs = ReadToEnd();
|
var rs = ReadToEnd();
|
||||||
if (rs.IsSuccess)
|
if (!rs.IsSuccess)
|
||||||
return rs.StdOut.Split('\0', System.StringSplitOptions.RemoveEmptyEntries);
|
return [];
|
||||||
|
|
||||||
return [];
|
var lines = rs.StdOut.Split('\0', System.StringSplitOptions.RemoveEmptyEntries);
|
||||||
|
var outs = new List<string>();
|
||||||
|
foreach (var line in lines)
|
||||||
|
outs.Add(line);
|
||||||
|
return outs;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -814,14 +814,11 @@ namespace SourceGit.ViewModels
|
||||||
Task.Run(() =>
|
Task.Run(() =>
|
||||||
{
|
{
|
||||||
var files = new Commands.QueryRevisionFileNames(_repo.FullPath, sha).Result();
|
var files = new Commands.QueryRevisionFileNames(_repo.FullPath, sha).Result();
|
||||||
var filesList = new List<string>();
|
|
||||||
filesList.AddRange(files);
|
|
||||||
|
|
||||||
Dispatcher.UIThread.Invoke(() =>
|
Dispatcher.UIThread.Invoke(() =>
|
||||||
{
|
{
|
||||||
if (sha == Commit.SHA)
|
if (sha == Commit.SHA)
|
||||||
{
|
{
|
||||||
_revisionFiles = filesList;
|
_revisionFiles = files;
|
||||||
if (!string.IsNullOrEmpty(_revisionFileSearchFilter))
|
if (!string.IsNullOrEmpty(_revisionFileSearchFilter))
|
||||||
CalcRevisionFileSearchSuggestion();
|
CalcRevisionFileSearchSuggestion();
|
||||||
}
|
}
|
||||||
|
|
|
@ -2376,17 +2376,11 @@ namespace SourceGit.ViewModels
|
||||||
|
|
||||||
Task.Run(() =>
|
Task.Run(() =>
|
||||||
{
|
{
|
||||||
var files = new Commands.QueryRevisionFileNames(_fullpath, "HEAD").Result();
|
_worktreeFiles = new Commands.QueryRevisionFileNames(_fullpath, "HEAD").Result();
|
||||||
Dispatcher.UIThread.Invoke(() =>
|
Dispatcher.UIThread.Invoke(() =>
|
||||||
{
|
{
|
||||||
if (!IsSearchingCommitsByFilePath())
|
if (IsSearchingCommitsByFilePath())
|
||||||
return;
|
CalcMatchedFilesForSearching();
|
||||||
|
|
||||||
_worktreeFiles = new List<string>();
|
|
||||||
foreach (var f in files)
|
|
||||||
_worktreeFiles.Add(f);
|
|
||||||
|
|
||||||
CalcMatchedFilesForSearching();
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue