mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-05-12 21:05:48 +02:00
Use confirmation popup for amending last commit.
This commit is contained in:
parent
b6b21bc98e
commit
28fe3d6cf9
6 changed files with 24 additions and 27 deletions
|
@ -12,8 +12,7 @@ func (gui *Gui) handleCommitConfirm(g *gocui.Gui, v *gocui.View) error {
|
||||||
if message == "" {
|
if message == "" {
|
||||||
return gui.createErrorPanel(g, gui.Tr.SLocalize("CommitWithoutMessageErr"))
|
return gui.createErrorPanel(g, gui.Tr.SLocalize("CommitWithoutMessageErr"))
|
||||||
}
|
}
|
||||||
amendCommit := v.Title == gui.Tr.SLocalize("AmendLastCommit")
|
sub, err := gui.GitCommand.Commit(message, false)
|
||||||
sub, err := gui.GitCommand.Commit(message, amendCommit)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// TODO need to find a way to send through this error
|
// TODO need to find a way to send through this error
|
||||||
if err != gui.Errors.ErrSubProcess {
|
if err != gui.Errors.ErrSubProcess {
|
||||||
|
|
|
@ -201,14 +201,7 @@ func (gui *Gui) handleCommitPress(g *gocui.Gui, filesView *gocui.View) error {
|
||||||
if len(gui.stagedFiles()) == 0 && !gui.State.HasMergeConflicts {
|
if len(gui.stagedFiles()) == 0 && !gui.State.HasMergeConflicts {
|
||||||
return gui.createErrorPanel(g, gui.Tr.SLocalize("NoStagedFilesToCommit"))
|
return gui.createErrorPanel(g, gui.Tr.SLocalize("NoStagedFilesToCommit"))
|
||||||
}
|
}
|
||||||
|
|
||||||
commitMessageView := gui.getCommitMessageView(g)
|
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.Update(func(g *gocui.Gui) error {
|
||||||
g.SetViewOnTop("commitMessage")
|
g.SetViewOnTop("commitMessage")
|
||||||
gui.switchFocus(g, filesView, commitMessageView)
|
gui.switchFocus(g, filesView, commitMessageView)
|
||||||
|
@ -222,20 +215,17 @@ func (gui *Gui) handleAmendCommitPress(g *gocui.Gui, filesView *gocui.View) erro
|
||||||
if len(gui.stagedFiles()) == 0 && !gui.State.HasMergeConflicts {
|
if len(gui.stagedFiles()) == 0 && !gui.State.HasMergeConflicts {
|
||||||
return gui.createErrorPanel(g, gui.Tr.SLocalize("NoStagedFilesToCommit"))
|
return gui.createErrorPanel(g, gui.Tr.SLocalize("NoStagedFilesToCommit"))
|
||||||
}
|
}
|
||||||
commitMessageView := gui.getCommitMessageView(g)
|
title := strings.Title(gui.Tr.SLocalize("AmendLastCommit"))
|
||||||
commitMessageView.Clear()
|
question := gui.Tr.SLocalize("SureToAmend")
|
||||||
commitMessageView.Title = gui.Tr.SLocalize("AmendLastCommit")
|
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 {
|
||||||
|
gui.createErrorPanel(g, err.Error())
|
||||||
|
}
|
||||||
|
|
||||||
g.Update(func(g *gocui.Gui) error {
|
return gui.refreshFiles(g)
|
||||||
g.SetViewOnTop("commitMessage")
|
}, nil)
|
||||||
gui.switchFocus(g, filesView, commitMessageView)
|
|
||||||
lastCommitName := gui.State.Commits[0].Name
|
|
||||||
commitMessageView.Write([]byte(lastCommitName))
|
|
||||||
commitMessageView.SetCursor(len(lastCommitName), 0)
|
|
||||||
gui.RenderCommitLength()
|
|
||||||
return nil
|
|
||||||
})
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// handleCommitEditorPress - handle when the user wants to commit changes via
|
// handleCommitEditorPress - handle when the user wants to commit changes via
|
||||||
|
|
|
@ -2,7 +2,6 @@ package gui
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/jesseduffield/gocui"
|
"github.com/jesseduffield/gocui"
|
||||||
"strings"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// Binding - a keybinding mapping a key and modifier to a handler. The keypress
|
// Binding - a keybinding mapping a key and modifier to a handler. The keypress
|
||||||
|
@ -131,7 +130,7 @@ func (gui *Gui) GetKeybindings() []*Binding {
|
||||||
Key: 'M',
|
Key: 'M',
|
||||||
Modifier: gocui.ModNone,
|
Modifier: gocui.ModNone,
|
||||||
Handler: gui.handleAmendCommitPress,
|
Handler: gui.handleAmendCommitPress,
|
||||||
Description: strings.ToLower(gui.Tr.SLocalize("AmendLastCommit")),
|
Description: gui.Tr.SLocalize("AmendLastCommit"),
|
||||||
}, {
|
}, {
|
||||||
ViewName: "files",
|
ViewName: "files",
|
||||||
Key: 'C',
|
Key: 'C',
|
||||||
|
|
|
@ -36,7 +36,10 @@ func addDutch(i18nObject *i18n.Bundle) error {
|
||||||
Other: "Commit Veranderingen",
|
Other: "Commit Veranderingen",
|
||||||
}, &i18n.Message{
|
}, &i18n.Message{
|
||||||
ID: "AmendLastCommit",
|
ID: "AmendLastCommit",
|
||||||
Other: "Wijzig laatste commit",
|
Other: "wijzig laatste commit",
|
||||||
|
}, &i18n.Message{
|
||||||
|
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{
|
}, &i18n.Message{
|
||||||
ID: "CommitChangesWithEditor",
|
ID: "CommitChangesWithEditor",
|
||||||
Other: "commit Veranderingen met de git editor",
|
Other: "commit Veranderingen met de git editor",
|
||||||
|
|
|
@ -44,7 +44,10 @@ func addEnglish(i18nObject *i18n.Bundle) error {
|
||||||
Other: "commit changes",
|
Other: "commit changes",
|
||||||
}, &i18n.Message{
|
}, &i18n.Message{
|
||||||
ID: "AmendLastCommit",
|
ID: "AmendLastCommit",
|
||||||
Other: "Amend last commit",
|
Other: "amend last commit",
|
||||||
|
}, &i18n.Message{
|
||||||
|
ID: "SureToAmend",
|
||||||
|
Other: "Are you sure you want to amend last commit? You can change commit message from commits panel.",
|
||||||
}, &i18n.Message{
|
}, &i18n.Message{
|
||||||
ID: "CommitChangesWithEditor",
|
ID: "CommitChangesWithEditor",
|
||||||
Other: "commit changes using git editor",
|
Other: "commit changes using git editor",
|
||||||
|
|
|
@ -34,7 +34,10 @@ func addPolish(i18nObject *i18n.Bundle) error {
|
||||||
Other: "commituj zmiany",
|
Other: "commituj zmiany",
|
||||||
}, &i18n.Message{
|
}, &i18n.Message{
|
||||||
ID: "AmendLastCommit",
|
ID: "AmendLastCommit",
|
||||||
Other: "Zmień ostatnie zatwierdzenie",
|
Other: "zmień ostatnie zatwierdzenie",
|
||||||
|
}, &i18n.Message{
|
||||||
|
ID: "SureToAmend",
|
||||||
|
Other: "Czy na pewno chcesz zmienić ostatnie zatwierdzenie? Możesz zmienić komunikat zatwierdzenia z panelu zatwierdzeń.",
|
||||||
}, &i18n.Message{
|
}, &i18n.Message{
|
||||||
ID: "CommitChangesWithEditor",
|
ID: "CommitChangesWithEditor",
|
||||||
Other: "commituj zmiany używając edytora z gita",
|
Other: "commituj zmiany używając edytora z gita",
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue