feature: supports type change

This commit is contained in:
leo 2024-07-30 21:32:23 +08:00
parent 7f8b8a19a0
commit 3c5a661fa0
No known key found for this signature in database
3 changed files with 35 additions and 1 deletions

View file

@ -39,6 +39,9 @@ namespace SourceGit.Commands
case " M": case " M":
change.Set(Models.ChangeState.None, Models.ChangeState.Modified); change.Set(Models.ChangeState.None, Models.ChangeState.Modified);
break; break;
case " T":
change.Set(Models.ChangeState.None, Models.ChangeState.TypeChanged);
break;
case " A": case " A":
change.Set(Models.ChangeState.None, Models.ChangeState.Added); change.Set(Models.ChangeState.None, Models.ChangeState.Added);
break; break;
@ -57,15 +60,33 @@ namespace SourceGit.Commands
case "MM": case "MM":
change.Set(Models.ChangeState.Modified, Models.ChangeState.Modified); change.Set(Models.ChangeState.Modified, Models.ChangeState.Modified);
break; break;
case "MT":
change.Set(Models.ChangeState.Modified, Models.ChangeState.TypeChanged);
break;
case "MD": case "MD":
change.Set(Models.ChangeState.Modified, Models.ChangeState.Deleted); change.Set(Models.ChangeState.Modified, Models.ChangeState.Deleted);
break; break;
case "T":
change.Set(Models.ChangeState.TypeChanged);
break;
case "TM":
change.Set(Models.ChangeState.TypeChanged, Models.ChangeState.Modified);
break;
case "TT":
change.Set(Models.ChangeState.TypeChanged, Models.ChangeState.TypeChanged);
break;
case "TD":
change.Set(Models.ChangeState.TypeChanged, Models.ChangeState.Deleted);
break;
case "A": case "A":
change.Set(Models.ChangeState.Added); change.Set(Models.ChangeState.Added);
break; break;
case "AM": case "AM":
change.Set(Models.ChangeState.Added, Models.ChangeState.Modified); change.Set(Models.ChangeState.Added, Models.ChangeState.Modified);
break; break;
case "AT":
change.Set(Models.ChangeState.Added, Models.ChangeState.TypeChanged);
break;
case "AD": case "AD":
change.Set(Models.ChangeState.Added, Models.ChangeState.Deleted); change.Set(Models.ChangeState.Added, Models.ChangeState.Deleted);
break; break;
@ -78,6 +99,9 @@ namespace SourceGit.Commands
case "RM": case "RM":
change.Set(Models.ChangeState.Renamed, Models.ChangeState.Modified); change.Set(Models.ChangeState.Renamed, Models.ChangeState.Modified);
break; break;
case "RT":
change.Set(Models.ChangeState.Renamed, Models.ChangeState.TypeChanged);
break;
case "RD": case "RD":
change.Set(Models.ChangeState.Renamed, Models.ChangeState.Deleted); change.Set(Models.ChangeState.Renamed, Models.ChangeState.Deleted);
break; break;
@ -87,6 +111,9 @@ namespace SourceGit.Commands
case "CM": case "CM":
change.Set(Models.ChangeState.Copied, Models.ChangeState.Modified); change.Set(Models.ChangeState.Copied, Models.ChangeState.Modified);
break; break;
case "CT":
change.Set(Models.ChangeState.Copied, Models.ChangeState.TypeChanged);
break;
case "CD": case "CD":
change.Set(Models.ChangeState.Copied, Models.ChangeState.Deleted); change.Set(Models.ChangeState.Copied, Models.ChangeState.Deleted);
break; break;

View file

@ -13,6 +13,7 @@ namespace SourceGit.Models
{ {
None, None,
Modified, Modified,
TypeChanged,
Added, Added,
Deleted, Deleted,
Renamed, Renamed,

View file

@ -18,6 +18,12 @@ namespace SourceGit.Views
EndPoint = new RelativePoint(0, 1, RelativeUnit.Relative), EndPoint = new RelativePoint(0, 1, RelativeUnit.Relative),
}, },
new LinearGradientBrush new LinearGradientBrush
{
GradientStops = new GradientStops() { new GradientStop(Color.FromRgb(238, 160, 14), 0), new GradientStop(Color.FromRgb(228, 172, 67), 1) },
StartPoint = new RelativePoint(0, 0, RelativeUnit.Relative),
EndPoint = new RelativePoint(0, 1, RelativeUnit.Relative),
},
new LinearGradientBrush
{ {
GradientStops = new GradientStops() { new GradientStop(Color.FromRgb(47, 185, 47), 0), new GradientStop(Color.FromRgb(75, 189, 75), 1) }, GradientStops = new GradientStops() { new GradientStop(Color.FromRgb(47, 185, 47), 0), new GradientStop(Color.FromRgb(75, 189, 75), 1) },
StartPoint = new RelativePoint(0, 0, RelativeUnit.Relative), StartPoint = new RelativePoint(0, 0, RelativeUnit.Relative),
@ -55,7 +61,7 @@ namespace SourceGit.Views
}, },
]; ];
private static readonly string[] INDICATOR = ["?", "±", "+", "", "➜", "❏", "U", "★"]; private static readonly string[] INDICATOR = ["?", "±", "T", "+", "", "➜", "❏", "U", "★"];
public static readonly StyledProperty<bool> IsUnstagedChangeProperty = public static readonly StyledProperty<bool> IsUnstagedChangeProperty =
AvaloniaProperty.Register<ChangeStatusIcon, bool>(nameof(IsUnstagedChange)); AvaloniaProperty.Register<ChangeStatusIcon, bool>(nameof(IsUnstagedChange));