Skip to content

Commit c8fe1e5

Browse files
feature: add fixup head into parent
1 parent a999d09 commit c8fe1e5

File tree

3 files changed

+27
-0
lines changed

3 files changed

+27
-0
lines changed

src/Resources/Locales/en_US.axaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@
156156
<x:String x:Key="Text.CommitCM.Reword" xml:space="preserve">Reword</x:String>
157157
<x:String x:Key="Text.CommitCM.SaveAsPatch" xml:space="preserve">Save as Patch...</x:String>
158158
<x:String x:Key="Text.CommitCM.Squash" xml:space="preserve">Squash into Parent</x:String>
159+
<x:String x:Key="Text.CommitCM.Fixup" xml:space="preserve">Fixup into Parent</x:String>
159160
<x:String x:Key="Text.CommitDetail.Changes" xml:space="preserve">CHANGES</x:String>
160161
<x:String x:Key="Text.CommitDetail.Changes.Count" xml:space="preserve">changed file(s)</x:String>
161162
<x:String x:Key="Text.CommitDetail.Changes.Search" xml:space="preserve">Search Changes...</x:String>

src/ViewModels/Histories.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,21 @@ public async Task SquashHeadAsync(Models.Commit head)
341341
}
342342
}
343343

344+
public async Task FixupHeadAsync(Models.Commit head)
345+
{
346+
if (head.Parents.Count == 1)
347+
{
348+
var parent = await new Commands.QuerySingleCommit(_repo.FullPath, head.Parents[0]).GetResultAsync();
349+
if (parent == null)
350+
return;
351+
352+
var parentMessage = await new Commands.QueryCommitFullMessage(_repo.FullPath, head.Parents[0]).GetResultAsync();
353+
354+
if (_repo.CanCreatePopup())
355+
await _repo.ShowAndStartPopupAsync(new Squash(_repo, parent, parentMessage));
356+
}
357+
}
358+
344359
public async Task DropHeadAsync(Models.Commit head)
345360
{
346361
var parent = _commits.Find(x => x.SHA.Equals(head.Parents[0]));

src/Views/Histories.axaml.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -563,6 +563,17 @@ private ContextMenu CreateContextMenuForSingleCommit(ViewModels.Repository repo,
563563
e.Handled = true;
564564
};
565565
menu.Items.Add(squash);
566+
567+
var fixup = new MenuItem();
568+
fixup.Header = App.Text("CommitCM.Fixup");
569+
fixup.Icon = App.CreateMenuIcon("Icons.Fix");
570+
fixup.IsEnabled = commit.Parents.Count == 1;
571+
fixup.Click += async (_, e) =>
572+
{
573+
await vm.FixupHeadAsync(commit);
574+
e.Handled = true;
575+
};
576+
menu.Items.Add(fixup);
566577
}
567578
else
568579
{

0 commit comments

Comments
 (0)