mirror of
https://github.com/sourcegit-scm/sourcegit.git
synced 2024-10-31 13:03:20 -07:00
fix: submodule diff missing commit message
This commit is contained in:
parent
4ec93b9d75
commit
c3cbb6d895
3 changed files with 30 additions and 8 deletions
|
@ -587,10 +587,16 @@ namespace SourceGit.Models
|
|||
public string New { get; set; } = string.Empty;
|
||||
}
|
||||
|
||||
public class SubmoduleRevision
|
||||
{
|
||||
public Commit Commit { get; set; } = null;
|
||||
public string FullMessage { get; set; } = string.Empty;
|
||||
}
|
||||
|
||||
public class SubmoduleDiff
|
||||
{
|
||||
public Commit Old { get; set; } = null;
|
||||
public Commit New { get; set; } = null;
|
||||
public SubmoduleRevision Old { get; set; } = null;
|
||||
public SubmoduleRevision New { get; set; } = null;
|
||||
}
|
||||
|
||||
public class DiffResult
|
||||
|
|
|
@ -131,12 +131,12 @@ namespace SourceGit.ViewModels
|
|||
if (line.Type == Models.TextDiffLineType.Added)
|
||||
{
|
||||
var sha = line.Content.Substring("Subproject commit ".Length);
|
||||
submoduleDiff.New = new Commands.QuerySingleCommit(submoduleRoot, sha).Result() ?? new Models.Commit() { SHA = sha };
|
||||
submoduleDiff.New = QuerySubmoduleRevision(submoduleRoot, sha);
|
||||
}
|
||||
else if (line.Type == Models.TextDiffLineType.Deleted)
|
||||
{
|
||||
var sha = line.Content.Substring("Subproject commit ".Length);
|
||||
submoduleDiff.Old = new Commands.QuerySingleCommit(submoduleRoot, sha).Result() ?? new Models.Commit() { SHA = sha };
|
||||
submoduleDiff.Old = QuerySubmoduleRevision(submoduleRoot, sha);
|
||||
}
|
||||
}
|
||||
rs = submoduleDiff;
|
||||
|
@ -219,6 +219,22 @@ namespace SourceGit.ViewModels
|
|||
return size > 0 ? (new Bitmap(stream), size) : (null, size);
|
||||
}
|
||||
|
||||
private Models.SubmoduleRevision QuerySubmoduleRevision(string repo, string sha)
|
||||
{
|
||||
var commit = new Commands.QuerySingleCommit(repo, sha).Result();
|
||||
if (commit != null)
|
||||
{
|
||||
var body = new Commands.QueryCommitFullMessage(repo, sha).Result();
|
||||
return new Models.SubmoduleRevision() { Commit = commit, FullMessage = body };
|
||||
}
|
||||
|
||||
return new Models.SubmoduleRevision()
|
||||
{
|
||||
Commit = new Models.Commit() { SHA = sha },
|
||||
FullMessage = string.Empty,
|
||||
};
|
||||
}
|
||||
|
||||
private static readonly HashSet<string> IMG_EXTS = new HashSet<string>()
|
||||
{
|
||||
".ico", ".bmp", ".jpg", ".png", ".jpeg"
|
||||
|
|
|
@ -151,9 +151,9 @@
|
|||
<Border IsVisible="{Binding Old, Converter={x:Static ObjectConverters.IsNotNull}}">
|
||||
<ContentControl Content="{Binding Old}">
|
||||
<ContentControl.DataTemplates>
|
||||
<DataTemplate DataType="m:Commit">
|
||||
<DataTemplate DataType="m:SubmoduleRevision">
|
||||
<Border Margin="0,0,0,8" BorderThickness="1" BorderBrush="{DynamicResource Brush.Border1}" Background="{DynamicResource Brush.Window}">
|
||||
<v:CommitBaseInfo MaxHeight="256" Margin="0,0,0,4" CanNavigate="False" Content="{Binding}"/>
|
||||
<v:CommitBaseInfo MaxHeight="256" Margin="0,0,0,4" CanNavigate="False" Content="{Binding Commit}" Message="{Binding FullMessage}"/>
|
||||
</Border>
|
||||
</DataTemplate>
|
||||
</ContentControl.DataTemplates>
|
||||
|
@ -167,7 +167,7 @@
|
|||
<Path Width="16" Height="16" Data="{StaticResource Icons.DoubleDown}" HorizontalAlignment="Center" IsVisible="{Binding Old, Converter={x:Static ObjectConverters.IsNotNull}}"/>
|
||||
|
||||
<Border Margin="0,8,0,0" BorderThickness="1" BorderBrush="Green" Background="{DynamicResource Brush.Window}">
|
||||
<v:CommitBaseInfo MaxHeight="256" Margin="0,0,0,4" CanNavigate="False" Content="{Binding New}"/>
|
||||
<v:CommitBaseInfo MaxHeight="256" Margin="0,0,0,4" CanNavigate="False" Content="{Binding New.Commit}" Message="{Binding New.FullMessage}"/>
|
||||
</Border>
|
||||
</StackPanel>
|
||||
</ScrollViewer>
|
||||
|
@ -239,7 +239,7 @@
|
|||
UseSideBySideDiff="{Binding Source={x:Static vm:Preference.Instance}, Path=UseSideBySideDiff, Mode=OneWay}"/>
|
||||
</DataTemplate>
|
||||
|
||||
<!-- No or only EOL changes -->
|
||||
<!-- Empty or only EOL changes -->
|
||||
<DataTemplate DataType="m:NoOrEOLChange">
|
||||
<StackPanel Orientation="Vertical" VerticalAlignment="Center">
|
||||
<Path Width="64" Height="64" Data="{StaticResource Icons.Check}" Fill="{DynamicResource Brush.FG2}"/>
|
||||
|
|
Loading…
Reference in a new issue