diff options
author | Daniele D'Orazio <d.dorazio96@gmail.com> | 2018-08-29 14:27:17 +0200 |
---|---|---|
committer | Daniele D'Orazio <d.dorazio96@gmail.com> | 2018-09-01 12:14:42 +0200 |
commit | 9e6a4a529af999b7c6b2adefe16632f2e19c5b8a (patch) | |
tree | a926c78ab48897564f5a60c6958f73bd5b39ca8a /pkg | |
parent | b65fa852f187c820901e67f77b1fb8ac8dbd4ea3 (diff) |
add keybinding to open user editor when renaming last commit
Diffstat (limited to 'pkg')
-rw-r--r-- | pkg/commands/git.go | 5 | ||||
-rw-r--r-- | pkg/gui/commits_panel.go | 13 | ||||
-rw-r--r-- | pkg/gui/keybindings.go | 1 |
3 files changed, 19 insertions, 0 deletions
diff --git a/pkg/commands/git.go b/pkg/commands/git.go index 619db05e7..704a45c73 100644 --- a/pkg/commands/git.go +++ b/pkg/commands/git.go @@ -422,6 +422,11 @@ func (c *GitCommand) PrepareCommitSubProcess() *exec.Cmd { return c.OSCommand.PrepareSubProcess("git", "commit") } +// PrepareCommitAmendSubProcess prepares a subprocess for `git commit --amend --allow-empty` +func (c *GitCommand) PrepareCommitAmendSubProcess() *exec.Cmd { + return c.OSCommand.PrepareSubProcess("git", "commit", "--amend", "--allow-empty") +} + // GetBranchGraph gets the color-formatted graph of the log for the given branch // Currently it limits the result to 100 commits, but when we get async stuff // working we can do lazy loading diff --git a/pkg/gui/commits_panel.go b/pkg/gui/commits_panel.go index c428e3b99..0969692b6 100644 --- a/pkg/gui/commits_panel.go +++ b/pkg/gui/commits_panel.go @@ -155,6 +155,19 @@ func (gui *Gui) handleRenameCommit(g *gocui.Gui, v *gocui.View) error { return nil } +func (gui *Gui) handleRenameCommitEditor(g *gocui.Gui, v *gocui.View) error { + if gui.getItemPosition(v) != 0 { + return gui.createErrorPanel(g, gui.Tr.SLocalize("OnlyRenameTopCommit")) + } + + gui.SubProcess = gui.GitCommand.PrepareCommitAmendSubProcess() + g.Update(func(g *gocui.Gui) error { + return gui.Errors.ErrSubProcess + }) + + return nil +} + func (gui *Gui) getSelectedCommit(g *gocui.Gui) (commands.Commit, error) { v, err := g.View("commits") if err != nil { diff --git a/pkg/gui/keybindings.go b/pkg/gui/keybindings.go index 52496b918..b09358fac 100644 --- a/pkg/gui/keybindings.go +++ b/pkg/gui/keybindings.go @@ -64,6 +64,7 @@ func (gui *Gui) keybindings(g *gocui.Gui) error { {ViewName: "branches", Key: 'm', Modifier: gocui.ModNone, Handler: gui.handleMerge}, {ViewName: "commits", Key: 's', Modifier: gocui.ModNone, Handler: gui.handleCommitSquashDown}, {ViewName: "commits", Key: 'r', Modifier: gocui.ModNone, Handler: gui.handleRenameCommit}, + {ViewName: "commits", Key: 'R', Modifier: gocui.ModNone, Handler: gui.handleRenameCommitEditor}, {ViewName: "commits", Key: 'g', Modifier: gocui.ModNone, Handler: gui.handleResetToCommit}, {ViewName: "commits", Key: 'f', Modifier: gocui.ModNone, Handler: gui.handleCommitFixup}, {ViewName: "stash", Key: gocui.KeySpace, Modifier: gocui.ModNone, Handler: gui.handleStashApply}, |