fix: show a empty commit with sha in submodule diff view if commit has been dropped

This commit is contained in:
leo 2024-06-05 13:54:52 +08:00
parent 1870dcd468
commit 78000b6d1a
No known key found for this signature in database
GPG key ID: B528468E49CD0E58

View file

@ -131,12 +131,12 @@ namespace SourceGit.ViewModels
if (line.Type == Models.TextDiffLineType.Added) if (line.Type == Models.TextDiffLineType.Added)
{ {
var sha = line.Content.Substring("Subproject commit ".Length); var sha = line.Content.Substring("Subproject commit ".Length);
submoduleDiff.New = new Commands.QuerySingleCommit(submoduleRoot, sha).Result(); submoduleDiff.New = new Commands.QuerySingleCommit(submoduleRoot, sha).Result() ?? new Models.Commit() { SHA = sha };
} }
else if (line.Type == Models.TextDiffLineType.Deleted) else if (line.Type == Models.TextDiffLineType.Deleted)
{ {
var sha = line.Content.Substring("Subproject commit ".Length); var sha = line.Content.Substring("Subproject commit ".Length);
submoduleDiff.Old = new Commands.QuerySingleCommit(submoduleRoot, sha).Result(); submoduleDiff.Old = new Commands.QuerySingleCommit(submoduleRoot, sha).Result() ?? new Models.Commit() { SHA = sha };
} }
} }
rs = submoduleDiff; rs = submoduleDiff;