diff options
author | Kristijan Husak <husakkristijan@gmail.com> | 2018-10-08 21:19:45 +0200 |
---|---|---|
committer | Kristijan Husak <husakkristijan@gmail.com> | 2018-10-08 21:19:45 +0200 |
commit | 190309e5c1c939b4de5c366b31dea265e78cb4f3 (patch) | |
tree | c3995abad5686f2ddc2e6f64b1c22fc1575101fe | |
parent | ac65586bd551adbac4c738e01bf8c7b216c16418 (diff) |
Check if there is any commit to amend and use 'A' instead of 'M' as shortcut.
-rw-r--r-- | pkg/commands/git.go | 4 | ||||
-rw-r--r-- | pkg/gui/files_panel.go | 5 | ||||
-rw-r--r-- | pkg/gui/keybindings.go | 4 | ||||
-rw-r--r-- | pkg/i18n/dutch.go | 3 | ||||
-rw-r--r-- | pkg/i18n/english.go | 3 | ||||
-rw-r--r-- | pkg/i18n/polish.go | 3 |
6 files changed, 18 insertions, 4 deletions
diff --git a/pkg/commands/git.go b/pkg/commands/git.go index c7de19b3a..ffaf9fce6 100644 --- a/pkg/commands/git.go +++ b/pkg/commands/git.go @@ -317,9 +317,9 @@ func (c *GitCommand) usingGpg() bool { func (c *GitCommand) Commit(message string, amend bool) (*exec.Cmd, error) { amendParam := "" if amend { - amendParam = "--amend " + amendParam = "--amend" } - command := fmt.Sprintf("git commit %s-m %s", amendParam, c.OSCommand.Quote(message)) + command := fmt.Sprintf("git commit %s -m %s", amendParam, c.OSCommand.Quote(message)) if c.usingGpg() { return c.OSCommand.PrepareSubProcess(c.OSCommand.Platform.shell, c.OSCommand.Platform.shellArg, command), nil } diff --git a/pkg/gui/files_panel.go b/pkg/gui/files_panel.go index b16492dfd..19d7b9342 100644 --- a/pkg/gui/files_panel.go +++ b/pkg/gui/files_panel.go @@ -217,6 +217,11 @@ func (gui *Gui) handleAmendCommitPress(g *gocui.Gui, filesView *gocui.View) erro } 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) diff --git a/pkg/gui/keybindings.go b/pkg/gui/keybindings.go index b242028c6..78271a3f7 100644 --- a/pkg/gui/keybindings.go +++ b/pkg/gui/keybindings.go @@ -127,7 +127,7 @@ func (gui *Gui) GetKeybindings() []*Binding { Description: gui.Tr.SLocalize("CommitChanges"), }, { ViewName: "files", - Key: 'M', + Key: 'A', Modifier: gocui.ModNone, Handler: gui.handleAmendCommitPress, Description: gui.Tr.SLocalize("AmendLastCommit"), @@ -188,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"), diff --git a/pkg/i18n/dutch.go b/pkg/i18n/dutch.go index 56e93fdc6..6b24a5174 100644 --- a/pkg/i18n/dutch.go +++ b/pkg/i18n/dutch.go @@ -41,6 +41,9 @@ func addDutch(i18nObject *i18n.Bundle) error { ID: "SureToAmend", Other: "Weet je zeker dat je de laatste commit wilt wijzigen? U kunt het commit-bericht wijzigen vanuit het commits-paneel.", }, &i18n.Message{ + ID: "NoCommitToAmend", + Other: "Er is geen verplichting om te wijzigen.", + }, &i18n.Message{ ID: "CommitChangesWithEditor", Other: "commit Veranderingen met de git editor", }, &i18n.Message{ diff --git a/pkg/i18n/english.go b/pkg/i18n/english.go index 41ce71bd2..9ead5a54e 100644 --- a/pkg/i18n/english.go +++ b/pkg/i18n/english.go @@ -49,6 +49,9 @@ func addEnglish(i18nObject *i18n.Bundle) error { ID: "SureToAmend", Other: "Are you sure you want to amend last commit? You can change commit message from commits panel.", }, &i18n.Message{ + ID: "NoCommitToAmend", + Other: "There's no commit to amend.", + }, &i18n.Message{ ID: "CommitChangesWithEditor", Other: "commit changes using git editor", }, &i18n.Message{ diff --git a/pkg/i18n/polish.go b/pkg/i18n/polish.go index 74b4106a5..c37bfe972 100644 --- a/pkg/i18n/polish.go +++ b/pkg/i18n/polish.go @@ -39,6 +39,9 @@ func addPolish(i18nObject *i18n.Bundle) error { ID: "SureToAmend", Other: "Czy na pewno chcesz zmienić ostatnie zatwierdzenie? Możesz zmienić komunikat zatwierdzenia z panelu zatwierdzeń.", }, &i18n.Message{ + ID: "NoCommitToAmend", + Other: "Nie ma zobowiązania do zmiany.", + }, &i18n.Message{ ID: "CommitChangesWithEditor", Other: "commituj zmiany używając edytora z gita", }, &i18n.Message{ |