From 83f23583be039203802ae6d331ffc1a3120eaeba Mon Sep 17 00:00:00 2001 From: leo Date: Fri, 7 Mar 2025 12:22:47 +0800 Subject: [PATCH] enhance: supports to navigate to target commit while resolving conflicts Signed-off-by: leo --- src/ViewModels/Conflict.cs | 10 ++-------- src/Views/WorkingCopy.axaml | 22 ++++++++++++---------- src/Views/WorkingCopy.axaml.cs | 10 ++++++++++ 3 files changed, 24 insertions(+), 18 deletions(-) diff --git a/src/ViewModels/Conflict.cs b/src/ViewModels/Conflict.cs index 41a0a137..153a8d4f 100644 --- a/src/ViewModels/Conflict.cs +++ b/src/ViewModels/Conflict.cs @@ -35,14 +35,8 @@ } else if (context is RebaseInProgress rebase) { - Theirs = repo.Branches.Find(x => x.IsLocal && x.Name == rebase.HeadName) ?? - new Models.Branch() - { - IsLocal = true, - Name = rebase.HeadName, - FullName = $"refs/heads/{rebase.HeadName}" - }; - + var b = repo.Branches.Find(x => x.IsLocal && x.Name == rebase.HeadName); + Theirs = (object)b ?? rebase.StoppedAt; Mine = rebase.Onto; } else if (context is RevertInProgress revert) diff --git a/src/Views/WorkingCopy.axaml b/src/Views/WorkingCopy.axaml index 0120eda5..e5728df2 100644 --- a/src/Views/WorkingCopy.axaml +++ b/src/Views/WorkingCopy.axaml @@ -211,7 +211,12 @@ - + @@ -225,18 +230,15 @@ FontSize="11" VerticalAlignment="Center" UseGraphColor="False"/> - + - - - - - - - - diff --git a/src/Views/WorkingCopy.axaml.cs b/src/Views/WorkingCopy.axaml.cs index 4ae4d779..04674f86 100644 --- a/src/Views/WorkingCopy.axaml.cs +++ b/src/Views/WorkingCopy.axaml.cs @@ -1,6 +1,7 @@ using Avalonia.Controls; using Avalonia.Input; using Avalonia.Interactivity; +using Avalonia.VisualTree; namespace SourceGit.Views { @@ -159,5 +160,14 @@ namespace SourceGit.Views e.Handled = true; } + + private void OnPressedSHA(object sender, PointerPressedEventArgs e) + { + var repoView = this.FindAncestorOfType(); + if (repoView is { DataContext: ViewModels.Repository repo } && sender is TextBlock text) + repo.NavigateToCommit(text.Text); + + e.Handled = true; + } } }