Skip to content

Commit 93d39c8

Browse files
2KAbhishekstefanhaller
authored andcommitted
Add commit menu entry "Add co-author"
1 parent a945502 commit 93d39c8

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
@@ -5,6 +5,7 @@ import (
55
"strings"
66
"time"
77

8+
"github.com/jesseduffield/lazygit/pkg/commands/git_commands"
89
"github.com/jesseduffield/lazygit/pkg/gui/types"
910
"github.com/samber/lo"
1011
)
@@ -196,9 +197,29 @@ func (self *CommitsHelper) OpenCommitMenu(suggestionFunc func(string) []*types.S
196197
},
197198
Key: 'e',
198199
},
200+
{
201+
Label: self.c.Tr.AddCoAuthor,
202+
OnPress: func() error {
203+
return self.addCoAuthor(suggestionFunc)
204+
},
205+
Key: 'c',
206+
},
199207
}
200208
return self.c.Menu(types.CreateMenuOptions{
201209
Title: self.c.Tr.CommitMenuTitle,
202210
Items: menuItems,
203211
})
204212
}
213+
214+
func (self *CommitsHelper) addCoAuthor(suggestionFunc func(string) []*types.Suggestion) error {
215+
return self.c.Prompt(types.PromptOpts{
216+
Title: self.c.Tr.AddCoAuthorPromptTitle,
217+
FindSuggestionsFunc: suggestionFunc,
218+
HandleConfirm: func(value string) error {
219+
commitDescription := self.getCommitDescription()
220+
commitDescription = git_commands.AddCoAuthorToDescription(commitDescription, value)
221+
self.setCommitDescription(commitDescription)
222+
return nil
223+
},
224+
})
225+
}

0 commit comments

Comments
 (0)