mirror of
https://github.com/sourcegit-scm/sourcegit.git
synced 2024-11-01 13:13:21 -07: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
|
@ -582,6 +582,12 @@ namespace SourceGit.Models
|
||||||
public string New { get; set; } = string.Empty;
|
public string New { get; set; } = string.Empty;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class SubmoduleDiff
|
||||||
|
{
|
||||||
|
public Commit Old { get; set; } = null;
|
||||||
|
public Commit New { get; set; } = null;
|
||||||
|
}
|
||||||
|
|
||||||
public class DiffResult
|
public class DiffResult
|
||||||
{
|
{
|
||||||
public bool IsBinary { get; set; } = false;
|
public bool IsBinary { get; set; } = false;
|
||||||
|
|
|
@ -161,6 +161,8 @@
|
||||||
<x:String x:Key="Text.Diff.NoChange" xml:space="preserve">NO CHANGES OR ONLY EOL CHANGES</x:String>
|
<x:String x:Key="Text.Diff.NoChange" xml:space="preserve">NO CHANGES OR ONLY EOL CHANGES</x:String>
|
||||||
<x:String x:Key="Text.Diff.Prev" xml:space="preserve">Previous Difference</x:String>
|
<x:String x:Key="Text.Diff.Prev" xml:space="preserve">Previous Difference</x:String>
|
||||||
<x:String x:Key="Text.Diff.SideBySide" xml:space="preserve">Side-By-Side Diff</x:String>
|
<x:String x:Key="Text.Diff.SideBySide" xml:space="preserve">Side-By-Side Diff</x:String>
|
||||||
|
<x:String x:Key="Text.Diff.Submodule" xml:space="preserve">SUBMODULE</x:String>
|
||||||
|
<x:String x:Key="Text.Diff.Submodule.New" xml:space="preserve">NEW</x:String>
|
||||||
<x:String x:Key="Text.Diff.SyntaxHighlight" xml:space="preserve">Syntax Highlighting</x:String>
|
<x:String x:Key="Text.Diff.SyntaxHighlight" xml:space="preserve">Syntax Highlighting</x:String>
|
||||||
<x:String x:Key="Text.Diff.UseMerger" xml:space="preserve">Open In Merge Tool</x:String>
|
<x:String x:Key="Text.Diff.UseMerger" xml:space="preserve">Open In Merge Tool</x:String>
|
||||||
<x:String x:Key="Text.Diff.VisualLines.Decr" xml:space="preserve">Decrease Number of Visible Lines</x:String>
|
<x:String x:Key="Text.Diff.VisualLines.Decr" xml:space="preserve">Decrease Number of Visible Lines</x:String>
|
||||||
|
|
|
@ -161,6 +161,8 @@
|
||||||
<x:String x:Key="Text.Diff.NoChange" xml:space="preserve">没有变更或仅有换行符差异</x:String>
|
<x:String x:Key="Text.Diff.NoChange" xml:space="preserve">没有变更或仅有换行符差异</x:String>
|
||||||
<x:String x:Key="Text.Diff.Prev" xml:space="preserve">上一个差异</x:String>
|
<x:String x:Key="Text.Diff.Prev" xml:space="preserve">上一个差异</x:String>
|
||||||
<x:String x:Key="Text.Diff.SideBySide" xml:space="preserve">分列对比</x:String>
|
<x:String x:Key="Text.Diff.SideBySide" xml:space="preserve">分列对比</x:String>
|
||||||
|
<x:String x:Key="Text.Diff.Submodule" xml:space="preserve">子模块</x:String>
|
||||||
|
<x:String x:Key="Text.Diff.Submodule.New" xml:space="preserve">新增</x:String>
|
||||||
<x:String x:Key="Text.Diff.SyntaxHighlight" xml:space="preserve">语法高亮</x:String>
|
<x:String x:Key="Text.Diff.SyntaxHighlight" xml:space="preserve">语法高亮</x:String>
|
||||||
<x:String x:Key="Text.Diff.UseMerger" xml:space="preserve">使用外部合并工具查看</x:String>
|
<x:String x:Key="Text.Diff.UseMerger" xml:space="preserve">使用外部合并工具查看</x:String>
|
||||||
<x:String x:Key="Text.Diff.VisualLines.Decr" xml:space="preserve">减少可见的行数</x:String>
|
<x:String x:Key="Text.Diff.VisualLines.Decr" xml:space="preserve">减少可见的行数</x:String>
|
||||||
|
|
|
@ -72,7 +72,7 @@
|
||||||
<Style Selector="TextBlock.italic">
|
<Style Selector="TextBlock.italic">
|
||||||
<Setter Property="FontStyle" Value="Italic"/>
|
<Setter Property="FontStyle" Value="Italic"/>
|
||||||
</Style>
|
</Style>
|
||||||
<Style Selector="TextBlock.monospace">
|
<Style Selector="TextBlock.monospace, SelectableTextBlock.monospace">
|
||||||
<Setter Property="FontFamily" Value="{Binding Source={x:Static vm:Preference.Instance}, Path=MonospaceFont}"/>
|
<Setter Property="FontFamily" Value="{Binding Source={x:Static vm:Preference.Instance}, Path=MonospaceFont}"/>
|
||||||
</Style>
|
</Style>
|
||||||
<Style Selector="TextBlock.group_header_label">
|
<Style Selector="TextBlock.group_header_label">
|
||||||
|
|
|
@ -123,8 +123,31 @@ namespace SourceGit.ViewModels
|
||||||
|
|
||||||
if (latest.TextDiff != null)
|
if (latest.TextDiff != null)
|
||||||
{
|
{
|
||||||
latest.TextDiff.File = _option.Path;
|
var repo = Preference.FindRepository(_repo);
|
||||||
rs = latest.TextDiff;
|
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)
|
else if (latest.IsBinary)
|
||||||
{
|
{
|
||||||
|
@ -182,7 +205,7 @@ namespace SourceGit.ViewModels
|
||||||
|
|
||||||
FileModeChange = latest.FileModeChange;
|
FileModeChange = latest.FileModeChange;
|
||||||
Content = rs;
|
Content = rs;
|
||||||
IsTextDiff = latest.TextDiff != null;
|
IsTextDiff = rs is Models.TextDiff;
|
||||||
IsLoading = false;
|
IsLoading = false;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -111,9 +111,6 @@
|
||||||
<SelectableTextBlock Text="{Binding FullMessage}" FontFamily="{Binding Source={x:Static vm:Preference.Instance}, Path=MonospaceFont}" TextWrapping="Wrap"/>
|
<SelectableTextBlock Text="{Binding FullMessage}" FontFamily="{Binding Source={x:Static vm:Preference.Instance}, Path=MonospaceFont}" TextWrapping="Wrap"/>
|
||||||
</ScrollViewer>
|
</ScrollViewer>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|
||||||
<!-- Line -->
|
|
||||||
<Rectangle Height=".65" Margin="8" Fill="{DynamicResource Brush.Border2}" VerticalAlignment="Center"/>
|
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</DataTemplate>
|
</DataTemplate>
|
||||||
</UserControl.DataTemplates>
|
</UserControl.DataTemplates>
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
using Avalonia;
|
||||||
using Avalonia.Controls;
|
using Avalonia.Controls;
|
||||||
using Avalonia.Input;
|
using Avalonia.Input;
|
||||||
|
|
||||||
|
@ -5,6 +6,15 @@ namespace SourceGit.Views
|
||||||
{
|
{
|
||||||
public partial class CommitBaseInfo : UserControl
|
public partial class CommitBaseInfo : UserControl
|
||||||
{
|
{
|
||||||
|
public static readonly StyledProperty<bool> CanNavigateProperty =
|
||||||
|
AvaloniaProperty.Register<CommitBaseInfo, bool>(nameof(CanNavigate), true);
|
||||||
|
|
||||||
|
public bool CanNavigate
|
||||||
|
{
|
||||||
|
get => GetValue(CanNavigateProperty);
|
||||||
|
set => SetValue(CanNavigateProperty, value);
|
||||||
|
}
|
||||||
|
|
||||||
public CommitBaseInfo()
|
public CommitBaseInfo()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
@ -12,10 +22,9 @@ namespace SourceGit.Views
|
||||||
|
|
||||||
private void OnParentSHAPressed(object sender, PointerPressedEventArgs e)
|
private void OnParentSHAPressed(object sender, PointerPressedEventArgs e)
|
||||||
{
|
{
|
||||||
if (DataContext is ViewModels.CommitDetail detail)
|
if (DataContext is ViewModels.CommitDetail detail && CanNavigate)
|
||||||
{
|
|
||||||
detail.NavigateTo((sender as Control).DataContext as string);
|
detail.NavigateTo((sender as Control).DataContext as string);
|
||||||
}
|
|
||||||
e.Handled = true;
|
e.Handled = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,12 +17,15 @@
|
||||||
<TextBlock Classes="tab_header" Text="{DynamicResource Text.CommitDetail.Info}"/>
|
<TextBlock Classes="tab_header" Text="{DynamicResource Text.CommitDetail.Info}"/>
|
||||||
</TabItem.Header>
|
</TabItem.Header>
|
||||||
|
|
||||||
<Grid RowDefinitions="Auto,*">
|
<Grid RowDefinitions="Auto,1,*">
|
||||||
<!-- Base Information -->
|
<!-- Base Information -->
|
||||||
<v:CommitBaseInfo Grid.Row="0" Content="{Binding Commit}"/>
|
<v:CommitBaseInfo Grid.Row="0" Content="{Binding Commit}"/>
|
||||||
|
|
||||||
|
<!-- Line -->
|
||||||
|
<Rectangle Grid.Row="1" Height=".65" Margin="8" Fill="{DynamicResource Brush.Border2}" VerticalAlignment="Center"/>
|
||||||
|
|
||||||
<!-- Change List -->
|
<!-- Change List -->
|
||||||
<DataGrid Grid.Row="1"
|
<DataGrid Grid.Row="2"
|
||||||
Background="Transparent"
|
Background="Transparent"
|
||||||
ItemsSource="{Binding Changes}"
|
ItemsSource="{Binding Changes}"
|
||||||
SelectionMode="Single"
|
SelectionMode="Single"
|
||||||
|
|
|
@ -126,6 +126,44 @@
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</DataTemplate>
|
</DataTemplate>
|
||||||
|
|
||||||
|
<!-- Submodule Diff -->
|
||||||
|
<DataTemplate DataType="m:SubmoduleDiff">
|
||||||
|
<Grid Background="{DynamicResource Brush.Contents}" RowDefinitions="Auto,*">
|
||||||
|
<TextBlock Grid.Row="0"
|
||||||
|
Text="{DynamicResource Text.Diff.Submodule}"
|
||||||
|
Margin="8,8,8,8"
|
||||||
|
FontSize="18" FontWeight="Bold"
|
||||||
|
Foreground="{DynamicResource Brush.FG2}"
|
||||||
|
HorizontalAlignment="Center"/>
|
||||||
|
|
||||||
|
<ScrollViewer Grid.Row="1" HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Auto">
|
||||||
|
<StackPanel Orientation="Vertical" Margin="8,0">
|
||||||
|
<Border IsVisible="{Binding Old, Converter={x:Static ObjectConverters.IsNotNull}}">
|
||||||
|
<ContentControl Content="{Binding Old}">
|
||||||
|
<ContentControl.DataTemplates>
|
||||||
|
<DataTemplate DataType="m:Commit">
|
||||||
|
<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}"/>
|
||||||
|
</Border>
|
||||||
|
</DataTemplate>
|
||||||
|
</ContentControl.DataTemplates>
|
||||||
|
</ContentControl>
|
||||||
|
</Border>
|
||||||
|
|
||||||
|
<Border Height="16" HorizontalAlignment="Center" Background="Green" CornerRadius="8" IsVisible="{Binding Old, Converter={x:Static ObjectConverters.IsNull}}">
|
||||||
|
<TextBlock Classes="monospace" Text="{DynamicResource Text.Diff.Submodule.New}" Margin="8,0" FontSize="10"/>
|
||||||
|
</Border>
|
||||||
|
|
||||||
|
<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}"/>
|
||||||
|
</Border>
|
||||||
|
</StackPanel>
|
||||||
|
</ScrollViewer>
|
||||||
|
</Grid>
|
||||||
|
</DataTemplate>
|
||||||
|
|
||||||
<!-- Image Diff -->
|
<!-- Image Diff -->
|
||||||
<DataTemplate DataType="m:ImageDiff">
|
<DataTemplate DataType="m:ImageDiff">
|
||||||
<Grid RowDefinitions="Auto,*,Auto" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="8,8,8,0">
|
<Grid RowDefinitions="Auto,*,Auto" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="8,8,8,0">
|
||||||
|
|
Loading…
Reference in a new issue