diff options
author | Gary Yendell <gary.yendell@diamond.ac.uk> | 2020-04-27 17:31:22 +0100 |
---|---|---|
committer | Jesse Duffield <jessedduffield@gmail.com> | 2020-05-09 11:59:37 +1000 |
commit | 7ed8ee160d7f1d38f5159dca315e56899de8c0b9 (patch) | |
tree | 51b95d8e77a392f5c40994a0d54372386af3030f /pkg/gui/patch_options_panel.go | |
parent | 3dd33b65a04b95c33b4cf154d41e8ab08d8aa9e2 (diff) |
Add option to split patch into a new commit
Add GetHeadCommitMessage to read the subject of the HEAD commit
Create PullPatchIntoNewCommit based heavily on PullPatchIntoIndex to
split the current patch from its commit and apply it in a separate
commit immediately after.
WIP to Squash - Fill format string with format string
WIP
Diffstat (limited to 'pkg/gui/patch_options_panel.go')
-rw-r--r-- | pkg/gui/patch_options_panel.go | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/pkg/gui/patch_options_panel.go b/pkg/gui/patch_options_panel.go index b69d12d92..4ec3cd228 100644 --- a/pkg/gui/patch_options_panel.go +++ b/pkg/gui/patch_options_panel.go @@ -21,6 +21,10 @@ func (gui *Gui) handleCreatePatchOptionsMenu(g *gocui.Gui, v *gocui.View) error onPress: gui.handlePullPatchIntoWorkingTree, }, { + displayString: "pull patch into new commit", + onPress: gui.handlePullPatchIntoNewCommit, + }, + { displayString: "apply patch", onPress: func() error { return gui.handleApplyPatch(false) }, }, @@ -137,6 +141,22 @@ func (gui *Gui) handlePullPatchIntoWorkingTree() error { } } +func (gui *Gui) handlePullPatchIntoNewCommit() error { + if ok, err := gui.validateNormalWorkingTreeState(); !ok { + return err + } + + if err := gui.returnFocusFromLineByLinePanelIfNecessary(); err != nil { + return err + } + + return gui.WithWaitingStatus(gui.Tr.SLocalize("RebasingStatus"), func() error { + commitIndex := gui.getPatchCommitIndex() + err := gui.GitCommand.PullPatchIntoNewCommit(gui.State.Commits, commitIndex, gui.GitCommand.PatchManager) + return gui.handleGenericMergeCommandResult(err) + }) +} + func (gui *Gui) handleApplyPatch(reverse bool) error { if err := gui.returnFocusFromLineByLinePanelIfNecessary(); err != nil { return err |