mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-05-12 04:45:47 +02:00
Add commit menu entry "Add co-author"
This commit is contained in:
parent
744519de60
commit
7c687938a5
1 changed files with 21 additions and 0 deletions
|
@ -6,6 +6,7 @@ import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/jesseduffield/gocui"
|
"github.com/jesseduffield/gocui"
|
||||||
|
"github.com/jesseduffield/lazygit/pkg/commands/git_commands"
|
||||||
"github.com/jesseduffield/lazygit/pkg/gui/types"
|
"github.com/jesseduffield/lazygit/pkg/gui/types"
|
||||||
"github.com/samber/lo"
|
"github.com/samber/lo"
|
||||||
)
|
)
|
||||||
|
@ -225,9 +226,29 @@ func (self *CommitsHelper) OpenCommitMenu(suggestionFunc func(string) []*types.S
|
||||||
},
|
},
|
||||||
Key: 'e',
|
Key: 'e',
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
Label: self.c.Tr.AddCoAuthor,
|
||||||
|
OnPress: func() error {
|
||||||
|
return self.addCoAuthor(suggestionFunc)
|
||||||
|
},
|
||||||
|
Key: 'c',
|
||||||
|
},
|
||||||
}
|
}
|
||||||
return self.c.Menu(types.CreateMenuOptions{
|
return self.c.Menu(types.CreateMenuOptions{
|
||||||
Title: self.c.Tr.CommitMenuTitle,
|
Title: self.c.Tr.CommitMenuTitle,
|
||||||
Items: menuItems,
|
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
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue