Skip to content

Commit 83f2358

Browse files
committed
enhance: supports to navigate to target commit while resolving conflicts
Signed-off-by: leo <longshuang@msn.cn>
1 parent ca6d41e commit 83f2358

File tree

3 files changed

+24
-18
lines changed

3 files changed

+24
-18
lines changed

src/ViewModels/Conflict.cs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,8 @@ public Conflict(Repository repo, WorkingCopy wc, Models.Change change)
3535
}
3636
else if (context is RebaseInProgress rebase)
3737
{
38-
Theirs = repo.Branches.Find(x => x.IsLocal && x.Name == rebase.HeadName) ??
39-
new Models.Branch()
40-
{
41-
IsLocal = true,
42-
Name = rebase.HeadName,
43-
FullName = $"refs/heads/{rebase.HeadName}"
44-
};
45-
38+
var b = repo.Branches.Find(x => x.IsLocal && x.Name == rebase.HeadName);
39+
Theirs = (object)b ?? rebase.StoppedAt;
4640
Mine = rebase.Onto;
4741
}
4842
else if (context is RevertInProgress revert)

src/Views/WorkingCopy.axaml

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,12 @@
211211
<StackPanel Orientation="Horizontal">
212212
<Path Width="12" Height="12" Data="{StaticResource Icons.Branch}"/>
213213
<TextBlock Margin="4,0,0,0" Text="{Binding FriendlyName}"/>
214-
<TextBlock Margin="4,0,0,0" Text="{Binding Head, Converter={x:Static c:StringConverters.ToShortSHA}}" Foreground="DarkOrange"/>
214+
<TextBlock Margin="4,0,0,0"
215+
Text="{Binding Head, Converter={x:Static c:StringConverters.ToShortSHA}}"
216+
Foreground="DarkOrange"
217+
TextDecorations="Underline"
218+
Cursor="Hand"
219+
PointerPressed="OnPressedSHA"/>
215220
</StackPanel>
216221
</DataTemplate>
217222

@@ -225,18 +230,15 @@
225230
FontSize="11"
226231
VerticalAlignment="Center"
227232
UseGraphColor="False"/>
228-
<TextBlock Margin="4,0,0,0" Text="{Binding SHA, Converter={x:Static c:StringConverters.ToShortSHA}}" Foreground="DarkOrange"/>
233+
<TextBlock Margin="4,0,0,0"
234+
Text="{Binding SHA, Converter={x:Static c:StringConverters.ToShortSHA}}"
235+
Foreground="DarkOrange"
236+
TextDecorations="Underline"
237+
Cursor="Hand"
238+
PointerPressed="OnPressedSHA"/>
229239
<TextBlock Margin="4,0,0,0" Text="{Binding Subject}"/>
230240
</StackPanel>
231241
</DataTemplate>
232-
233-
<DataTemplate DataType="m:Tag">
234-
<StackPanel Orientation="Horizontal">
235-
<Path Width="12" Height="12" Data="{StaticResource Icons.Tag}"/>
236-
<TextBlock Margin="4,0,0,0" Text="{Binding Name}"/>
237-
<TextBlock Margin="4,0,0,0" Text="{Binding SHA, Converter={x:Static c:StringConverters.ToShortSHA}}" Foreground="DarkOrange"/>
238-
</StackPanel>
239-
</DataTemplate>
240242
</StackPanel.DataTemplates>
241243

242244
<Path Width="64" Height="64" Data="{StaticResource Icons.Conflict}" Fill="{DynamicResource Brush.FG2}" HorizontalAlignment="Center"/>

src/Views/WorkingCopy.axaml.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using Avalonia.Controls;
22
using Avalonia.Input;
33
using Avalonia.Interactivity;
4+
using Avalonia.VisualTree;
45

56
namespace SourceGit.Views
67
{
@@ -159,5 +160,14 @@ private void OnOpenConventionalCommitHelper(object _, RoutedEventArgs e)
159160

160161
e.Handled = true;
161162
}
163+
164+
private void OnPressedSHA(object sender, PointerPressedEventArgs e)
165+
{
166+
var repoView = this.FindAncestorOfType<Repository>();
167+
if (repoView is { DataContext: ViewModels.Repository repo } && sender is TextBlock text)
168+
repo.NavigateToCommit(text.Text);
169+
170+
e.Handled = true;
171+
}
162172
}
163173
}

0 commit comments

Comments
 (0)