mirror of
https://github.com/sourcegit-scm/sourcegit
synced 2025-05-22 04:34:59 +00:00
feature: new way to display changes of submodules
This commit is contained in:
parent
1161738df9
commit
69f9dceece
9 changed files with 92 additions and 12 deletions
|
@ -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;
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue