1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-06-15 00:15:32 +02:00

Add coauthor (#2)

Add co-author to commits

Add addCoAuthor command for commits

- Implement the `addCoAuthor` command to add co-authors to commits.
- Utilize suggestions helpers to populate author names from the suggestions list.
- Added command to gui at `LocalCommitsController`.

This commit introduces the `addCoAuthor` command, which allows users to easily add co-authors to their commits. The co-author names are populated from the suggestions list, minimizing the chances of user input errors. The co-authors are added using the Co-authored-by metadata format recognized by GitHub and GitLab.
This commit is contained in:
Orlando Maussa
2023-09-09 07:18:47 -05:00
committed by GitHub
parent d7e2ca3f10
commit db409fa69f
6 changed files with 92 additions and 0 deletions

View File

@ -621,6 +621,12 @@ func (self *LocalCommitsController) amendAttribute(commit *models.Commit) error
Key: 'A',
Tooltip: "Set the author based on a prompt",
},
{
Label: self.c.Tr.AddCoAuthor,
OnPress: self.addCoAuthor,
Key: 'c',
Tooltip: self.c.Tr.AddCoAuthorTooltip,
},
},
})
}
@ -653,6 +659,22 @@ func (self *LocalCommitsController) setAuthor() error {
})
}
func (self *LocalCommitsController) addCoAuthor() error {
return self.c.Prompt(types.PromptOpts{
Title: self.c.Tr.AddCoAuthorPromptTitle,
FindSuggestionsFunc: self.c.Helpers().Suggestions.GetAuthorsSuggestionsFunc(),
HandleConfirm: func(value string) error {
return self.c.WithWaitingStatus(self.c.Tr.AmendingStatus, func(gocui.Task) error {
self.c.LogAction(self.c.Tr.Actions.AddCommitCoAuthor)
if err := self.c.Git().Rebase.AddCommitCoAuthor(self.c.Model().Commits, self.context().GetSelectedLineIdx(), value); err != nil {
return self.c.Error(err)
}
return self.c.Refresh(types.RefreshOptions{Mode: types.ASYNC})
})
},
})
}
func (self *LocalCommitsController) revert(commit *models.Commit) error {
if commit.IsMerge() {
return self.createRevertMergeCommitMenu(commit)