mirror of
https://fastgit.cc/github.com/sourcegit-scm/sourcegit
synced 2026-04-26 03:40:45 +08:00
code_review: PR #1472
Move `Commands.IsCommitSHA` testing from `Commands.QuerySingleCommit` to `ViewModels.Repository.StartSearchCommits`, because we only need test the SHA user typed in Signed-off-by: leo <longshuang@msn.cn>
This commit is contained in:
@@ -6,9 +6,6 @@ namespace SourceGit.Commands
|
||||
{
|
||||
public QuerySingleCommit(string repo, string sha)
|
||||
{
|
||||
_repo = repo;
|
||||
_sha = sha;
|
||||
|
||||
WorkingDirectory = repo;
|
||||
Context = repo;
|
||||
Args = $"show --no-show-signature --decorate=full --format=%H%n%P%n%D%n%aN±%aE%n%at%n%cN±%cE%n%ct%n%s -s {sha}";
|
||||
@@ -16,10 +13,6 @@ namespace SourceGit.Commands
|
||||
|
||||
public Models.Commit Result()
|
||||
{
|
||||
var isCommitSHA = new IsCommitSHA(_repo, _sha).Result();
|
||||
if (!isCommitSHA)
|
||||
return null;
|
||||
|
||||
var rs = ReadToEnd();
|
||||
if (rs.IsSuccess && !string.IsNullOrEmpty(rs.StdOut))
|
||||
{
|
||||
@@ -44,8 +37,5 @@ namespace SourceGit.Commands
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private readonly string _repo;
|
||||
private readonly string _sha;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -871,13 +871,17 @@ namespace SourceGit.ViewModels
|
||||
|
||||
Task.Run(() =>
|
||||
{
|
||||
List<Models.Commit> visible;
|
||||
List<Models.Commit> visible = [];
|
||||
var method = (Models.CommitSearchMethod)_searchCommitFilterType;
|
||||
|
||||
if (method == Models.CommitSearchMethod.BySHA)
|
||||
{
|
||||
var commit = new Commands.QuerySingleCommit(_fullpath, _searchCommitFilter).Result();
|
||||
visible = commit == null ? [] : [commit];
|
||||
var isCommitSHA = new Commands.IsCommitSHA(_fullpath, _searchCommitFilter).Result();
|
||||
if (isCommitSHA)
|
||||
{
|
||||
var commit = new Commands.QuerySingleCommit(_fullpath, _searchCommitFilter).Result();
|
||||
visible = [commit];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user