Skip to content

Commit 3ede806

Browse files
committed
Add new graph-highlight option "Selected Commits (only first-parent)"
1 parent 81dbfa5 commit 3ede806

3 files changed

Lines changed: 17 additions & 0 deletions

File tree

src/Models/CommitGraph.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ public enum CommitGraphHighlighting
1313
All = 0,
1414
CurrentBranchOnly,
1515
SelectedCommitsOnly,
16+
SelectedCommitsOnlyFirstParent,
1617
CurrentBranchAndSelectedCommits,
1718
}
1819

@@ -156,6 +157,7 @@ public static CommitGraph Generate(List<Commit> commits, bool firstParentOnlyEna
156157

157158
if (!isHighlighted &&
158159
(highlighting == CommitGraphHighlighting.SelectedCommitsOnly ||
160+
highlighting == CommitGraphHighlighting.SelectedCommitsOnlyFirstParent ||
159161
highlighting == CommitGraphHighlighting.CurrentBranchAndSelectedCommits))
160162
{
161163
isHighlighted = highlightExtraCommits.Remove(commit.SHA);
@@ -200,6 +202,9 @@ public static CommitGraph Generate(List<Commit> commits, bool firstParentOnlyEna
200202
// Deal with other parents (the first parent has been processed)
201203
if (!firstParentOnlyEnabled)
202204
{
205+
if (highlighting == CommitGraphHighlighting.SelectedCommitsOnlyFirstParent)
206+
isHighlighted = false;
207+
203208
for (int j = 1; j < commit.Parents.Count; j++)
204209
{
205210
var parentHash = commit.Parents[j];

src/Resources/Locales/en_US.axaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -518,6 +518,7 @@
518518
<x:String x:Key="Text.Histories.HighlightsInGraph.CurrentBranchOnly" xml:space="preserve">Current Branch Only</x:String>
519519
<x:String x:Key="Text.Histories.HighlightsInGraph.CurrentBranchAndSelectedCommits" xml:space="preserve">Current Branch &amp; Selected Commits</x:String>
520520
<x:String x:Key="Text.Histories.HighlightsInGraph.SelectedCommitsOnly" xml:space="preserve">Selected Commits Only</x:String>
521+
<x:String x:Key="Text.Histories.HighlightsInGraph.SelectedCommitsOnlyFirstParent" xml:space="preserve">Selected Commits (only first-parent)</x:String>
521522
<x:String x:Key="Text.Histories.Selected" xml:space="preserve">SELECTED {0} COMMITS</x:String>
522523
<x:String x:Key="Text.Histories.ShowColumns" xml:space="preserve">SHOW COLUMNS</x:String>
523524
<x:String x:Key="Text.Histories.Tips" xml:space="preserve">Hold 'Ctrl' or 'Shift' to select multiple commits.</x:String>

src/Views/Repository.axaml.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -487,6 +487,16 @@ private void OnOpenAdvancedHistoriesOption(object sender, RoutedEventArgs e)
487487
ev.Handled = true;
488488
};
489489

490+
var selectedCommitsOnlyFirstParent = new MenuItem();
491+
selectedCommitsOnlyFirstParent.Header = App.Text("Histories.HighlightsInGraph.SelectedCommitsOnlyFirstParent");
492+
if (histories.GraphHighlighting == Models.CommitGraphHighlighting.SelectedCommitsOnlyFirstParent)
493+
selectedCommitsOnlyFirstParent.Icon = this.CreateMenuIcon("Icons.Check");
494+
selectedCommitsOnlyFirstParent.Click += (_, ev) =>
495+
{
496+
histories.GraphHighlighting = Models.CommitGraphHighlighting.SelectedCommitsOnlyFirstParent;
497+
ev.Handled = true;
498+
};
499+
490500
var currentBranchAndSelectedCommits = new MenuItem();
491501
currentBranchAndSelectedCommits.Header = App.Text("Histories.HighlightsInGraph.CurrentBranchAndSelectedCommits");
492502
if (histories.GraphHighlighting == Models.CommitGraphHighlighting.CurrentBranchAndSelectedCommits)
@@ -516,6 +526,7 @@ private void OnOpenAdvancedHistoriesOption(object sender, RoutedEventArgs e)
516526
menu.Items.Add(all);
517527
menu.Items.Add(currentBranchOnly);
518528
menu.Items.Add(selectedCommitsOnly);
529+
menu.Items.Add(selectedCommitsOnlyFirstParent);
519530
menu.Items.Add(currentBranchAndSelectedCommits);
520531
menu.Open(button);
521532
}

0 commit comments

Comments
 (0)