mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-06-11 12:48:10 +03:00
Make it easy to create "amend!" commits
To support this, we turn the confirmation prompt of the "Create fixup commit" command into a menu; creating a fixup commit is the first entry, so that "shift-F, enter" behaves the same as before. But there are additional entries for creating "amend!" commits, either with or without file changes. These make it easy to reword commit messages of existing commits.
This commit is contained in:
@ -297,6 +297,21 @@ func (self *CommitCommands) CreateFixupCommit(sha string) error {
|
||||
return self.cmd.New(cmdArgs).Run()
|
||||
}
|
||||
|
||||
// CreateAmendCommit creates a commit that changes the commit message of a previous commit
|
||||
func (self *CommitCommands) CreateAmendCommit(originalSubject, newSubject, newDescription string, includeFileChanges bool) error {
|
||||
description := newSubject
|
||||
if newDescription != "" {
|
||||
description += "\n\n" + newDescription
|
||||
}
|
||||
cmdArgs := NewGitCmd("commit").
|
||||
Arg("-m", "amend! "+originalSubject).
|
||||
Arg("-m", description).
|
||||
ArgIf(!includeFileChanges, "--only", "--allow-empty").
|
||||
ToArgv()
|
||||
|
||||
return self.cmd.New(cmdArgs).Run()
|
||||
}
|
||||
|
||||
// a value of 0 means the head commit, 1 is the parent commit, etc
|
||||
func (self *CommitCommands) GetCommitMessageFromHistory(value int) (string, error) {
|
||||
cmdArgs := NewGitCmd("log").Arg("-1", fmt.Sprintf("--skip=%d", value), "--pretty=%H").
|
||||
|
Reference in New Issue
Block a user