mirror of
https://github.com/sourcegit-scm/sourcegit.git
synced 2024-12-24 20:57:19 -08:00
Merge pull request #69 from gadfly3173/feat/diff-file-mode
feat: show git file mode change if exist
This commit is contained in:
commit
1bb4d55a5c
6 changed files with 55 additions and 6 deletions
|
@ -1,6 +1,7 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
|
using SourceGit.Models;
|
||||||
|
|
||||||
namespace SourceGit.Commands
|
namespace SourceGit.Commands
|
||||||
{
|
{
|
||||||
|
@ -46,6 +47,22 @@ namespace SourceGit.Commands
|
||||||
|
|
||||||
protected override void OnReadline(string line)
|
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)
|
if (_result.IsBinary)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
|
@ -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 class DiffResult
|
||||||
{
|
{
|
||||||
public bool IsBinary { get; set; } = false;
|
public bool IsBinary { get; set; } = false;
|
||||||
public bool IsLFS { get; set; } = false;
|
public bool IsLFS { get; set; } = false;
|
||||||
public TextDiff TextDiff { get; set; } = null;
|
public TextDiff TextDiff { get; set; } = null;
|
||||||
public LFSDiff LFSDiff { 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.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.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.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.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.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>
|
<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.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.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.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.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.Next" xml:space="preserve">下一个差异</x:String>
|
||||||
<x:String x:Key="Text.Diff.NoChange" xml:space="preserve">没有变更或仅有换行符差异</x:String>
|
<x:String x:Key="Text.Diff.NoChange" xml:space="preserve">没有变更或仅有换行符差异</x:String>
|
||||||
|
|
|
@ -3,6 +3,7 @@ using System.IO;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
using Avalonia;
|
using Avalonia;
|
||||||
|
using Avalonia.Media;
|
||||||
using Avalonia.Media.Imaging;
|
using Avalonia.Media.Imaging;
|
||||||
using Avalonia.Threading;
|
using Avalonia.Threading;
|
||||||
|
|
||||||
|
@ -66,6 +67,14 @@ namespace SourceGit.ViewModels
|
||||||
set => SetProperty(ref _syncScrollOffset, value);
|
set => SetProperty(ref _syncScrollOffset, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Models.FileModeDiff FileModeDiff
|
||||||
|
{
|
||||||
|
get => _fileModeDiff;
|
||||||
|
set => SetProperty(ref _fileModeDiff, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public TextTrimming PathTrimming { get; } = new TextLeadingPrefixTrimming("...", 20);
|
||||||
|
|
||||||
public DiffContext(string repo, Models.DiffOption option, DiffContext previous = null)
|
public DiffContext(string repo, Models.DiffOption option, DiffContext previous = null)
|
||||||
{
|
{
|
||||||
_repo = repo;
|
_repo = repo;
|
||||||
|
@ -86,6 +95,11 @@ namespace SourceGit.ViewModels
|
||||||
var latest = new Commands.Diff(repo, option).Result();
|
var latest = new Commands.Diff(repo, option).Result();
|
||||||
var rs = null as object;
|
var rs = null as object;
|
||||||
|
|
||||||
|
if (latest.FileModeDiff != null)
|
||||||
|
{
|
||||||
|
FileModeDiff = latest.FileModeDiff;
|
||||||
|
}
|
||||||
|
|
||||||
if (latest.TextDiff != null)
|
if (latest.TextDiff != null)
|
||||||
{
|
{
|
||||||
latest.TextDiff.File = _option.Path;
|
latest.TextDiff.File = _option.Path;
|
||||||
|
@ -180,5 +194,6 @@ namespace SourceGit.ViewModels
|
||||||
private bool _isTextDiff = false;
|
private bool _isTextDiff = false;
|
||||||
private object _content = null;
|
private object _content = null;
|
||||||
private Vector _syncScrollOffset = Vector.Zero;
|
private Vector _syncScrollOffset = Vector.Zero;
|
||||||
|
private Models.FileModeDiff _fileModeDiff = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,20 +13,28 @@
|
||||||
<Grid RowDefinitions="26,*">
|
<Grid RowDefinitions="26,*">
|
||||||
<!-- Toolbar -->
|
<!-- Toolbar -->
|
||||||
<Border Grid.Row="0" BorderThickness="0,0,0,1" BorderBrush="{DynamicResource Brush.Border2}">
|
<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">
|
<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"/>
|
<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"/>
|
<TextBlock Classes="monospace" Margin="4,0,0,0" Text="{Binding OrgFilePath, Converter={x:Static c:PathConverters.TruncateIfTooLong}}" FontSize="11"/>
|
||||||
<TextBlock Margin="8,0,0,0" Text="→"/>
|
<TextBlock Margin="8,0,0,0" Text="→"/>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
|
||||||
<StackPanel Grid.Column="1" Orientation="Horizontal" VerticalAlignment="Center">
|
<DockPanel Grid.Column="1" VerticalAlignment="Center">
|
||||||
<Path Width="12" Height="12" Data="{StaticResource Icons.File}" Margin="8,0,0,0"/>
|
<Path DockPanel.Dock="Left" Width="12" Height="12" Data="{StaticResource Icons.File}" Margin="8,0,0,0"/>
|
||||||
<TextBlock Classes="monospace" Margin="4,0,0,0" Text="{Binding FilePath, Converter={x:Static c:PathConverters.TruncateIfTooLong}}" FontSize="11"/>
|
<TextBlock Classes="monospace" Margin="4,0,0,0" Text="{Binding FilePath}"
|
||||||
<Path Classes="rotating" Width="10" Height="10" Margin="8,0" Data="{DynamicResource Icons.Loading}" IsVisible="{Binding IsLoading}"/>
|
TextTrimming="{Binding PathTrimming}" TextWrapping="NoWrap" HorizontalAlignment="Stretch" ToolTip.Tip="{Binding FilePath}" FontSize="11"/>
|
||||||
|
<Path DockPanel.Dock="Right" Classes="rotating" Width="10" Height="10" Margin="8,0" Data="{StaticResource Icons.Loading}" IsVisible="{Binding IsLoading}"/>
|
||||||
|
</DockPanel>
|
||||||
|
|
||||||
|
<StackPanel Grid.Column="2" Orientation="Horizontal" VerticalAlignment="Center" IsVisible="{Binding FileModeDiff, Converter={x:Static 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>
|
||||||
|
|
||||||
<StackPanel Grid.Column="2" Margin="32,0,0,0" Orientation="Horizontal" VerticalAlignment="Center">
|
<StackPanel Grid.Column="3" Margin="32,0,0,0" Orientation="Horizontal" VerticalAlignment="Center">
|
||||||
<ToggleButton Classes="line_path"
|
<ToggleButton Classes="line_path"
|
||||||
Width="32" Height="18"
|
Width="32" Height="18"
|
||||||
Background="Transparent"
|
Background="Transparent"
|
||||||
|
|
Loading…
Reference in a new issue