mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-05-11 20:36:03 +02: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:
parent
c92e9d9bdc
commit
150cc70698
16 changed files with 707 additions and 505 deletions
|
@ -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").
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue