Skip to content

Commit bf4839d

Browse files
2KAbhishekstefanhaller
authored andcommitted
Add commit menu entry "Add co-author"
1 parent 7745bbb commit bf4839d

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

pkg/gui/controllers/helpers/commits_helper.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,13 @@ func (self *CommitsHelper) commitMessageContexts() []types.Context {
194194

195195
func (self *CommitsHelper) OpenCommitMenu(suggestionFunc func(string) []*types.Suggestion) error {
196196
menuItems := []*types.MenuItem{
197+
{
198+
Label: self.c.Tr.AddCoAuthor,
199+
OnPress: func() error {
200+
return self.addCoAuthor(suggestionFunc)
201+
},
202+
Key: 'c',
203+
},
197204
{
198205
Label: self.c.Tr.OpenInEditor,
199206
OnPress: func() error {
@@ -207,3 +214,16 @@ func (self *CommitsHelper) OpenCommitMenu(suggestionFunc func(string) []*types.S
207214
Items: menuItems,
208215
})
209216
}
217+
218+
func (self *CommitsHelper) addCoAuthor(suggestionFunc func(string) []*types.Suggestion) error {
219+
return self.c.Prompt(types.PromptOpts{
220+
Title: self.c.Tr.AddCoAuthorPromptTitle,
221+
FindSuggestionsFunc: suggestionFunc,
222+
HandleConfirm: func(value string) error {
223+
commitMessage := self.JoinCommitMessageAndDescription()
224+
coAuthorString := commitMessage + "\nCo-authored-by: " + value
225+
self.SetMessageAndDescriptionInView(coAuthorString)
226+
return nil
227+
},
228+
})
229+
}

0 commit comments

Comments
 (0)