summaryrefslogtreecommitdiffstats
path: root/pkg/gui/files_panel.go
diff options
context:
space:
mode:
authorKristijan Husak <husakkristijan@gmail.com>2018-09-12 15:20:35 +0200
committerKristijan Husak <husakkristijan@gmail.com>2018-09-13 12:44:32 +0200
commit61f0801bd366e959437676ae72b2d9fe98c4b8af (patch)
tree083ef07b6c8f759c2432a6e4b53df940441abf6f /pkg/gui/files_panel.go
parent7fb2cafd0cf6effbe660a933612d8c6783206749 (diff)
Add ammend commit action.
Diffstat (limited to 'pkg/gui/files_panel.go')
-rw-r--r--pkg/gui/files_panel.go27
1 files changed, 27 insertions, 0 deletions
diff --git a/pkg/gui/files_panel.go b/pkg/gui/files_panel.go
index bfcc938bb..235cb12d8 100644
--- a/pkg/gui/files_panel.go
+++ b/pkg/gui/files_panel.go
@@ -198,10 +198,37 @@ func (gui *Gui) handleCommitPress(g *gocui.Gui, filesView *gocui.View) error {
if len(gui.stagedFiles()) == 0 && !gui.State.HasMergeConflicts {
return gui.createErrorPanel(g, gui.Tr.SLocalize("NoStagedFilesToCommit"))
}
+
commitMessageView := gui.getCommitMessageView(g)
+ if commitMessageView.Title == gui.Tr.SLocalize("AmendLastCommit") {
+ commitMessageView.Clear()
+ commitMessageView.SetCursor(0, 0)
+ }
+
+ commitMessageView.Title = gui.Tr.SLocalize("CommitMessage")
+ g.Update(func(g *gocui.Gui) error {
+ g.SetViewOnTop("commitMessage")
+ gui.switchFocus(g, filesView, commitMessageView)
+ gui.RenderCommitLength()
+ return nil
+ })
+ return nil
+}
+
+func (gui *Gui) handleAmendCommitPress(g *gocui.Gui, filesView *gocui.View) error {
+ if len(gui.stagedFiles()) == 0 && !gui.State.HasMergeConflicts {
+ return gui.createErrorPanel(g, gui.Tr.SLocalize("NoStagedFilesToCommit"))
+ }
+ commitMessageView := gui.getCommitMessageView(g)
+ commitMessageView.Clear()
+ commitMessageView.Title = gui.Tr.SLocalize("AmendLastCommit")
+
g.Update(func(g *gocui.Gui) error {
g.SetViewOnTop("commitMessage")
gui.switchFocus(g, filesView, commitMessageView)
+ lastCommitName := gui.State.Commits[0].Name
+ commitMessageView.Write([]byte(lastCommitName))
+ commitMessageView.SetCursor(len(lastCommitName), 0)
gui.RenderCommitLength()
return nil
})