mirror of
https://github.com/sourcegit-scm/sourcegit.git
synced 2024-12-23 20:47:25 -08:00
feat: show git file mode change if exist
This commit is contained in:
parent
2d5e048797
commit
a249eed1ac
7 changed files with 61 additions and 2 deletions
|
@ -1,6 +1,7 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text.RegularExpressions;
|
||||
using SourceGit.Models;
|
||||
|
||||
namespace SourceGit.Commands
|
||||
{
|
||||
|
@ -46,6 +47,22 @@ namespace SourceGit.Commands
|
|||
|
||||
protected override void OnReadline(string line)
|
||||
{
|
||||
if (line.StartsWith("old mode ", StringComparison.Ordinal))
|
||||
{
|
||||
_result.FileModeDiff ??= new FileModeDiff();
|
||||
|
||||
_result.FileModeDiff.Old = line.Substring(9);
|
||||
return;
|
||||
}
|
||||
|
||||
if (line.StartsWith("new mode ", StringComparison.Ordinal))
|
||||
{
|
||||
_result.FileModeDiff ??= new FileModeDiff();
|
||||
|
||||
_result.FileModeDiff.New = line.Substring(9);
|
||||
return;
|
||||
}
|
||||
|
||||
if (_result.IsBinary)
|
||||
return;
|
||||
|
||||
|
|
13
src/Converters/ObjectConverters.cs
Normal file
13
src/Converters/ObjectConverters.cs
Normal file
|
@ -0,0 +1,13 @@
|
|||
using Avalonia.Data.Converters;
|
||||
|
||||
namespace SourceGit.Converters
|
||||
{
|
||||
public static class ObjectConverters
|
||||
{
|
||||
public static readonly FuncValueConverter<object, bool> IsNull =
|
||||
new FuncValueConverter<object, bool>(v => v == null);
|
||||
|
||||
public static readonly FuncValueConverter<object, bool> IsNotNull =
|
||||
new FuncValueConverter<object, bool>(v => v != null);
|
||||
}
|
||||
}
|
|
@ -576,11 +576,18 @@ namespace SourceGit.Models
|
|||
{
|
||||
}
|
||||
|
||||
public class FileModeDiff
|
||||
{
|
||||
public string Old { get; set; } = string.Empty;
|
||||
public string New { get; set; } = string.Empty;
|
||||
}
|
||||
|
||||
public class DiffResult
|
||||
{
|
||||
public bool IsBinary { get; set; } = false;
|
||||
public bool IsLFS { get; set; } = false;
|
||||
public TextDiff TextDiff { get; set; } = null;
|
||||
public LFSDiff LFSDiff { get; set; } = null;
|
||||
public FileModeDiff FileModeDiff { get; set; } = null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -131,6 +131,7 @@
|
|||
<x:String x:Key="Text.Diff.Binary.New" xml:space="preserve">NEW</x:String>
|
||||
<x:String x:Key="Text.Diff.Binary.Old" xml:space="preserve">OLD</x:String>
|
||||
<x:String x:Key="Text.Diff.Copy" xml:space="preserve">Copy</x:String>
|
||||
<x:String x:Key="Text.Diff.FileModeChanged" xml:space="preserve">File Mode Changed :</x:String>
|
||||
<x:String x:Key="Text.Diff.LFS" xml:space="preserve">LFS OBJECT CHANGE</x:String>
|
||||
<x:String x:Key="Text.Diff.Next" xml:space="preserve">Next Difference</x:String>
|
||||
<x:String x:Key="Text.Diff.NoChange" xml:space="preserve">NO CHANGES OR ONLY EOL CHANGES</x:String>
|
||||
|
|
|
@ -131,6 +131,7 @@
|
|||
<x:String x:Key="Text.Diff.Binary.New" xml:space="preserve">当前大小</x:String>
|
||||
<x:String x:Key="Text.Diff.Binary.Old" xml:space="preserve">原始大小</x:String>
|
||||
<x:String x:Key="Text.Diff.Copy" xml:space="preserve">复制</x:String>
|
||||
<x:String x:Key="Text.Diff.FileModeChanged" xml:space="preserve">文件权限已变化 :</x:String>
|
||||
<x:String x:Key="Text.Diff.LFS" xml:space="preserve">LFS对象变更</x:String>
|
||||
<x:String x:Key="Text.Diff.Next" xml:space="preserve">下一个差异</x:String>
|
||||
<x:String x:Key="Text.Diff.NoChange" xml:space="preserve">没有变更或仅有换行符差异</x:String>
|
||||
|
|
|
@ -7,6 +7,7 @@ using Avalonia.Media.Imaging;
|
|||
using Avalonia.Threading;
|
||||
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using SourceGit.Models;
|
||||
|
||||
namespace SourceGit.ViewModels
|
||||
{
|
||||
|
@ -66,6 +67,12 @@ namespace SourceGit.ViewModels
|
|||
set => SetProperty(ref _syncScrollOffset, value);
|
||||
}
|
||||
|
||||
public Models.FileModeDiff FileModeDiff
|
||||
{
|
||||
get => _fileModeDiff;
|
||||
set => SetProperty(ref _fileModeDiff, value);
|
||||
}
|
||||
|
||||
public DiffContext(string repo, Models.DiffOption option, DiffContext previous = null)
|
||||
{
|
||||
_repo = repo;
|
||||
|
@ -86,6 +93,11 @@ namespace SourceGit.ViewModels
|
|||
var latest = new Commands.Diff(repo, option).Result();
|
||||
var rs = null as object;
|
||||
|
||||
if (latest.FileModeDiff != null)
|
||||
{
|
||||
FileModeDiff = latest.FileModeDiff;
|
||||
}
|
||||
|
||||
if (latest.TextDiff != null)
|
||||
{
|
||||
latest.TextDiff.File = _option.Path;
|
||||
|
@ -180,5 +192,6 @@ namespace SourceGit.ViewModels
|
|||
private bool _isTextDiff = false;
|
||||
private object _content = null;
|
||||
private Vector _syncScrollOffset = Vector.Zero;
|
||||
private Models.FileModeDiff _fileModeDiff = null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
<Grid RowDefinitions="26,*">
|
||||
<!-- Toolbar -->
|
||||
<Border Grid.Row="0" BorderThickness="0,0,0,1" BorderBrush="{DynamicResource Brush.Border2}">
|
||||
<Grid ColumnDefinitions="Auto,*,Auto">
|
||||
<Grid ColumnDefinitions="Auto,Auto,*,Auto">
|
||||
<StackPanel Grid.Column="0" Orientation="Horizontal" IsVisible="{Binding IsOrgFilePathVisible}" VerticalAlignment="Center">
|
||||
<Path Width="12" Height="12" Data="{StaticResource Icons.File}" Margin="8,0,0,0"/>
|
||||
<TextBlock Classes="monospace" Margin="4,0,0,0" Text="{Binding OrgFilePath, Converter={x:Static c:PathConverters.TruncateIfTooLong}}" FontSize="11"/>
|
||||
|
@ -26,7 +26,14 @@
|
|||
<Path Classes="rotating" Width="10" Height="10" Margin="8,0" Data="{DynamicResource Icons.Loading}" IsVisible="{Binding IsLoading}"/>
|
||||
</StackPanel>
|
||||
|
||||
<StackPanel Grid.Column="2" Margin="32,0,0,0" Orientation="Horizontal" VerticalAlignment="Center">
|
||||
<StackPanel Grid.Column="2" Orientation="Horizontal" VerticalAlignment="Center" IsVisible="{Binding FileModeDiff, Converter={x:Static c:ObjectConverters.IsNotNull}}">
|
||||
<TextBlock Classes="monospace" Margin="8,0,0,0" Text="{DynamicResource Text.Diff.FileModeChanged}" FontSize="11"/>
|
||||
<TextBlock Classes="monospace" Text="{Binding FileModeDiff.Old}" FontSize="11"/>
|
||||
<TextBlock Margin="4,0" Text="→"/>
|
||||
<TextBlock Classes="monospace" Text="{Binding FileModeDiff.New}" FontSize="11"/>
|
||||
</StackPanel>
|
||||
|
||||
<StackPanel Grid.Column="3" Margin="32,0,0,0" Orientation="Horizontal" VerticalAlignment="Center">
|
||||
<ToggleButton Classes="line_path"
|
||||
Width="32" Height="18"
|
||||
Background="Transparent"
|
||||
|
|
Loading…
Reference in a new issue