summaryrefslogtreecommitdiffstats
path: root/pkg/gui
diff options
context:
space:
mode:
authorJesse Duffield <jessedduffield@gmail.com>2018-10-20 10:53:02 +1100
committerGitHub <noreply@github.com>2018-10-20 10:53:02 +1100
commit59cdd7d46e8a4ad50307b37bcd7fa2eb553cdfb3 (patch)
tree3785f4ce91fe4d51148b7a610e1426ef744b921a /pkg/gui
parentaf8d362caabee3bbf220ce0a9a58e7c4493cb2bb (diff)
parentd5f64602a8e10ab5c8162140d426ce677fe884ee (diff)
Merge branch 'master' into master
Diffstat (limited to 'pkg/gui')
-rw-r--r--pkg/gui/commit_message_panel.go2
-rw-r--r--pkg/gui/files_panel.go22
-rw-r--r--pkg/gui/keybindings.go8
3 files changed, 30 insertions, 2 deletions
diff --git a/pkg/gui/commit_message_panel.go b/pkg/gui/commit_message_panel.go
index 74e02be90..c26b5573a 100644
--- a/pkg/gui/commit_message_panel.go
+++ b/pkg/gui/commit_message_panel.go
@@ -12,7 +12,7 @@ func (gui *Gui) handleCommitConfirm(g *gocui.Gui, v *gocui.View) error {
if message == "" {
return gui.createErrorPanel(g, gui.Tr.SLocalize("CommitWithoutMessageErr"))
}
- sub, err := gui.GitCommand.Commit(message)
+ sub, err := gui.GitCommand.Commit(message, false)
if err != nil {
// TODO need to find a way to send through this error
if err != gui.Errors.ErrSubProcess {
diff --git a/pkg/gui/files_panel.go b/pkg/gui/files_panel.go
index 574e6bc1c..a00bd2843 100644
--- a/pkg/gui/files_panel.go
+++ b/pkg/gui/files_panel.go
@@ -211,6 +211,28 @@ func (gui *Gui) handleCommitPress(g *gocui.Gui, filesView *gocui.View) error {
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"))
+ }
+ title := strings.Title(gui.Tr.SLocalize("AmendLastCommit"))
+ question := gui.Tr.SLocalize("SureToAmend")
+
+ if len(gui.State.Commits) == 0 {
+ return gui.createErrorPanel(g, gui.Tr.SLocalize("NoCommitToAmend"))
+ }
+
+ return gui.createConfirmationPanel(g, filesView, title, question, func(g *gocui.Gui, v *gocui.View) error {
+ lastCommitMsg := gui.State.Commits[0].Name
+ _, err := gui.GitCommand.Commit(lastCommitMsg, true)
+ if err != nil {
+ return gui.createErrorPanel(g, err.Error())
+ }
+
+ return gui.refreshSidePanels(g)
+ }, nil)
+}
+
// handleCommitEditorPress - handle when the user wants to commit changes via
// their editor rather than via the popup panel
func (gui *Gui) handleCommitEditorPress(g *gocui.Gui, filesView *gocui.View) error {
diff --git a/pkg/gui/keybindings.go b/pkg/gui/keybindings.go
index 1073da68a..78271a3f7 100644
--- a/pkg/gui/keybindings.go
+++ b/pkg/gui/keybindings.go
@@ -127,6 +127,12 @@ func (gui *Gui) GetKeybindings() []*Binding {
Description: gui.Tr.SLocalize("CommitChanges"),
}, {
ViewName: "files",
+ Key: 'A',
+ Modifier: gocui.ModNone,
+ Handler: gui.handleAmendCommitPress,
+ Description: gui.Tr.SLocalize("AmendLastCommit"),
+ }, {
+ ViewName: "files",
Key: 'C',
Modifier: gocui.ModNone,
Handler: gui.handleCommitEditorPress,
@@ -182,7 +188,7 @@ func (gui *Gui) GetKeybindings() []*Binding {
Description: gui.Tr.SLocalize("stashFiles"),
}, {
ViewName: "files",
- Key: 'A',
+ Key: 'M',
Modifier: gocui.ModNone,
Handler: gui.handleAbortMerge,
Description: gui.Tr.SLocalize("abortMerge"),