diff --git a/pkg/gui/controllers/helpers/commits_helper.go b/pkg/gui/controllers/helpers/commits_helper.go index 31658f423..568c07726 100644 --- a/pkg/gui/controllers/helpers/commits_helper.go +++ b/pkg/gui/controllers/helpers/commits_helper.go @@ -6,6 +6,7 @@ import ( "time" "github.com/jesseduffield/gocui" + "github.com/jesseduffield/lazygit/pkg/commands/git_commands" "github.com/jesseduffield/lazygit/pkg/gui/types" "github.com/samber/lo" ) @@ -225,9 +226,29 @@ func (self *CommitsHelper) OpenCommitMenu(suggestionFunc func(string) []*types.S }, Key: 'e', }, + { + Label: self.c.Tr.AddCoAuthor, + OnPress: func() error { + return self.addCoAuthor(suggestionFunc) + }, + Key: 'c', + }, } return self.c.Menu(types.CreateMenuOptions{ Title: self.c.Tr.CommitMenuTitle, Items: menuItems, }) } + +func (self *CommitsHelper) addCoAuthor(suggestionFunc func(string) []*types.Suggestion) error { + return self.c.Prompt(types.PromptOpts{ + Title: self.c.Tr.AddCoAuthorPromptTitle, + FindSuggestionsFunc: suggestionFunc, + HandleConfirm: func(value string) error { + commitDescription := self.getCommitDescription() + commitDescription = git_commands.AddCoAuthorToDescription(commitDescription, value) + self.setCommitDescription(commitDescription) + return nil + }, + }) +}