Skip to content

Commit 7c68793

Browse files
2KAbhishekstefanhaller
authored andcommitted
Add commit menu entry "Add co-author"
1 parent 744519d commit 7c68793

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

pkg/gui/controllers/helpers/commits_helper.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"time"
77

88
"github.com/jesseduffield/gocui"
9+
"github.com/jesseduffield/lazygit/pkg/commands/git_commands"
910
"github.com/jesseduffield/lazygit/pkg/gui/types"
1011
"github.com/samber/lo"
1112
)
@@ -225,9 +226,29 @@ func (self *CommitsHelper) OpenCommitMenu(suggestionFunc func(string) []*types.S
225226
},
226227
Key: 'e',
227228
},
229+
{
230+
Label: self.c.Tr.AddCoAuthor,
231+
OnPress: func() error {
232+
return self.addCoAuthor(suggestionFunc)
233+
},
234+
Key: 'c',
235+
},
228236
}
229237
return self.c.Menu(types.CreateMenuOptions{
230238
Title: self.c.Tr.CommitMenuTitle,
231239
Items: menuItems,
232240
})
233241
}
242+
243+
func (self *CommitsHelper) addCoAuthor(suggestionFunc func(string) []*types.Suggestion) error {
244+
return self.c.Prompt(types.PromptOpts{
245+
Title: self.c.Tr.AddCoAuthorPromptTitle,
246+
FindSuggestionsFunc: suggestionFunc,
247+
HandleConfirm: func(value string) error {
248+
commitDescription := self.getCommitDescription()
249+
commitDescription = git_commands.AddCoAuthorToDescription(commitDescription, value)
250+
self.setCommitDescription(commitDescription)
251+
return nil
252+
},
253+
})
254+
}

0 commit comments

Comments
 (0)