mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-05-12 12:55:47 +02:00
Allow rewording for last commit using GPG
This commit is contained in:
parent
ce6388bdfa
commit
4a2508e960
4 changed files with 14 additions and 10 deletions
|
@ -117,7 +117,7 @@ func (self *CommitCommands) CommitInEditorWithMessageFileCmdObj(tmpMessageFile s
|
|||
}
|
||||
|
||||
// RewordLastCommit rewords the topmost commit with the given message
|
||||
func (self *CommitCommands) RewordLastCommit(summary string, description string) error {
|
||||
func (self *CommitCommands) RewordLastCommit(summary string, description string) oscommands.ICmdObj {
|
||||
messageArgs := self.commitMessageArgs(summary, description)
|
||||
|
||||
cmdArgs := NewGitCmd("commit").
|
||||
|
@ -125,7 +125,7 @@ func (self *CommitCommands) RewordLastCommit(summary string, description string)
|
|||
Arg(messageArgs...).
|
||||
ToArgv()
|
||||
|
||||
return self.cmd.New(cmdArgs).Run()
|
||||
return self.cmd.New(cmdArgs)
|
||||
}
|
||||
|
||||
func (self *CommitCommands) commitMessageArgs(summary string, description string) []string {
|
||||
|
|
|
@ -33,7 +33,7 @@ func TestCommitRewordCommit(t *testing.T) {
|
|||
t.Run(s.testName, func(t *testing.T) {
|
||||
instance := buildCommitCommands(commonDeps{runner: s.runner})
|
||||
|
||||
assert.NoError(t, instance.RewordLastCommit(s.summary, s.description))
|
||||
assert.NoError(t, instance.RewordLastCommit(s.summary, s.description).Run())
|
||||
s.runner.CheckForMissingCalls()
|
||||
})
|
||||
}
|
||||
|
|
|
@ -39,18 +39,13 @@ func (self *RebaseCommands) RewordCommit(commits []*models.Commit, index int, su
|
|||
return errors.New(self.Tr.DisabledForGPG)
|
||||
}
|
||||
|
||||
if models.IsHeadCommit(commits, index) {
|
||||
// we've selected the top commit so no rebase is required
|
||||
return self.commit.RewordLastCommit(summary, description)
|
||||
}
|
||||
|
||||
err := self.BeginInteractiveRebaseForCommit(commits, index, false)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// now the selected commit should be our head so we'll amend it with the new message
|
||||
err = self.commit.RewordLastCommit(summary, description)
|
||||
err = self.commit.RewordLastCommit(summary, description).Run()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue