mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-06-08 23:56:15 +02:00
Improve prompts when amending commits (#2980)
This commit is contained in:
commit
e2c447b8d0
@ -615,12 +615,18 @@ func (self *FilesController) refresh() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (self *FilesController) handleAmendCommitPress() error {
|
func (self *FilesController) handleAmendCommitPress() error {
|
||||||
return self.c.Helpers().WorkingTree.WithEnsureCommitableFiles(func() error {
|
return self.c.Confirm(types.ConfirmOpts{
|
||||||
if len(self.c.Model().Commits) == 0 {
|
Title: self.c.Tr.AmendLastCommitTitle,
|
||||||
return self.c.ErrorMsg(self.c.Tr.NoCommitToAmend)
|
Prompt: self.c.Tr.SureToAmend,
|
||||||
}
|
HandleConfirm: func() error {
|
||||||
|
return self.c.Helpers().WorkingTree.WithEnsureCommitableFiles(func() error {
|
||||||
|
if len(self.c.Model().Commits) == 0 {
|
||||||
|
return self.c.ErrorMsg(self.c.Tr.NoCommitToAmend)
|
||||||
|
}
|
||||||
|
|
||||||
return self.c.Helpers().AmendHelper.AmendHead()
|
return self.c.Helpers().AmendHelper.AmendHead()
|
||||||
|
})
|
||||||
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,9 +1,5 @@
|
|||||||
package helpers
|
package helpers
|
||||||
|
|
||||||
import (
|
|
||||||
"github.com/jesseduffield/lazygit/pkg/gui/types"
|
|
||||||
)
|
|
||||||
|
|
||||||
type AmendHelper struct {
|
type AmendHelper struct {
|
||||||
c *HelperCommon
|
c *HelperCommon
|
||||||
gpg *GpgHelper
|
gpg *GpgHelper
|
||||||
@ -20,13 +16,7 @@ func NewAmendHelper(
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (self *AmendHelper) AmendHead() error {
|
func (self *AmendHelper) AmendHead() error {
|
||||||
return self.c.Confirm(types.ConfirmOpts{
|
cmdObj := self.c.Git().Commit.AmendHeadCmdObj()
|
||||||
Title: self.c.Tr.AmendLastCommitTitle,
|
self.c.LogAction(self.c.Tr.Actions.AmendCommit)
|
||||||
Prompt: self.c.Tr.SureToAmend,
|
return self.gpg.WithGpgHandling(cmdObj, self.c.Tr.AmendingStatus, nil)
|
||||||
HandleConfirm: func() error {
|
|
||||||
cmdObj := self.c.Git().Commit.AmendHeadCmdObj()
|
|
||||||
self.c.LogAction(self.c.Tr.Actions.AmendCommit)
|
|
||||||
return self.gpg.WithGpgHandling(cmdObj, self.c.Tr.AmendingStatus, nil)
|
|
||||||
},
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
@ -568,11 +568,17 @@ func (self *LocalCommitsController) moveUp(commit *models.Commit) error {
|
|||||||
|
|
||||||
func (self *LocalCommitsController) amendTo(commit *models.Commit) error {
|
func (self *LocalCommitsController) amendTo(commit *models.Commit) error {
|
||||||
if self.isHeadCommit() {
|
if self.isHeadCommit() {
|
||||||
return self.c.Helpers().WorkingTree.WithEnsureCommitableFiles(func() error {
|
return self.c.Confirm(types.ConfirmOpts{
|
||||||
if err := self.c.Helpers().AmendHelper.AmendHead(); err != nil {
|
Title: self.c.Tr.AmendCommitTitle,
|
||||||
return err
|
Prompt: self.c.Tr.AmendCommitPrompt,
|
||||||
}
|
HandleConfirm: func() error {
|
||||||
return self.c.Refresh(types.RefreshOptions{Mode: types.ASYNC})
|
return self.c.Helpers().WorkingTree.WithEnsureCommitableFiles(func() error {
|
||||||
|
if err := self.c.Helpers().AmendHelper.AmendHead(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return self.c.Refresh(types.RefreshOptions{Mode: types.ASYNC})
|
||||||
|
})
|
||||||
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,8 +43,8 @@ var AmendHeadCommitDuringRebase = NewIntegrationTest(NewIntegrationTestArgs{
|
|||||||
Press(keys.Commits.AmendToCommit).
|
Press(keys.Commits.AmendToCommit).
|
||||||
Tap(func() {
|
Tap(func() {
|
||||||
t.ExpectPopup().Confirmation().
|
t.ExpectPopup().Confirmation().
|
||||||
Title(Equals("Amend last commit")).
|
Title(Equals("Amend commit")).
|
||||||
Content(Contains("Are you sure you want to amend last commit?")).
|
Content(Contains("Are you sure you want to amend this commit with your staged files?")).
|
||||||
Confirm()
|
Confirm()
|
||||||
}).
|
}).
|
||||||
Lines(
|
Lines(
|
||||||
|
@ -42,8 +42,8 @@ var AmendMerge = NewIntegrationTest(NewIntegrationTestArgs{
|
|||||||
Press(keys.Commits.AmendToCommit)
|
Press(keys.Commits.AmendToCommit)
|
||||||
|
|
||||||
t.ExpectPopup().Confirmation().
|
t.ExpectPopup().Confirmation().
|
||||||
Title(Equals("Amend last commit")).
|
Title(Equals("Amend commit")).
|
||||||
Content(Contains("Are you sure you want to amend last commit?")).
|
Content(Contains("Are you sure you want to amend this commit with your staged files?")).
|
||||||
Confirm()
|
Confirm()
|
||||||
|
|
||||||
// assuring we haven't added a brand new commit
|
// assuring we haven't added a brand new commit
|
||||||
|
Loading…
x
Reference in New Issue
Block a user