mirror of
https://fastgit.cc/github.com/sourcegit-scm/sourcegit
synced 2026-04-30 22:01:10 +08:00
feature: new way to display changes of submodules
This commit is contained in:
@@ -123,8 +123,31 @@ namespace SourceGit.ViewModels
|
||||
|
||||
if (latest.TextDiff != null)
|
||||
{
|
||||
latest.TextDiff.File = _option.Path;
|
||||
rs = latest.TextDiff;
|
||||
var repo = Preference.FindRepository(_repo);
|
||||
if (repo != null && repo.Submodules.Contains(_option.Path))
|
||||
{
|
||||
var submoduleDiff = new Models.SubmoduleDiff();
|
||||
var submoduleRoot = $"{_repo}/{_option.Path}".Replace("\\", "/");
|
||||
foreach (var line in latest.TextDiff.Lines)
|
||||
{
|
||||
if (line.Type == Models.TextDiffLineType.Added)
|
||||
{
|
||||
var sha = line.Content.Substring("Subproject commit ".Length);
|
||||
submoduleDiff.New = new Commands.QuerySingleCommit(submoduleRoot, sha).Result();
|
||||
}
|
||||
else if (line.Type == Models.TextDiffLineType.Deleted)
|
||||
{
|
||||
var sha = line.Content.Substring("Subproject commit ".Length);
|
||||
submoduleDiff.Old = new Commands.QuerySingleCommit(submoduleRoot, sha).Result();
|
||||
}
|
||||
}
|
||||
rs = submoduleDiff;
|
||||
}
|
||||
else
|
||||
{
|
||||
latest.TextDiff.File = _option.Path;
|
||||
rs = latest.TextDiff;
|
||||
}
|
||||
}
|
||||
else if (latest.IsBinary)
|
||||
{
|
||||
@@ -182,7 +205,7 @@ namespace SourceGit.ViewModels
|
||||
|
||||
FileModeChange = latest.FileModeChange;
|
||||
Content = rs;
|
||||
IsTextDiff = latest.TextDiff != null;
|
||||
IsTextDiff = rs is Models.TextDiff;
|
||||
IsLoading = false;
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user