mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-06-19 00:28:03 +02:00
.devcontainer
.github
.vscode
cmd
docs
pkg
app
cheatsheet
commands
common
config
constants
env
fakes
gui
context
controllers
helpers
attach.go
base_controller.go
basic_commits_controller.go
bisect_controller.go
branches_controller.go
commit_message_controller.go
commits_files_controller.go
common.go
context_lines_controller.go
files_controller.go
files_remove_controller.go
git_flow_controller.go
global_controller.go
list_controller.go
local_commits_controller.go
menu_controller.go
merge_conflicts_controller.go
patch_building_controller.go
patch_explorer_controller.go
remote_branches_controller.go
remotes_controller.go
snake_controller.go
staging_controller.go
stash_controller.go
submodules_controller.go
switch_to_diff_files_controller.go
switch_to_sub_commits_controller.go
sync_controller.go
tags_controller.go
types.go
undo_controller.go
vertical_scroll_controller.go
workspace_reset_controller.go
filetree
keybindings
mergeconflicts
modes
patch_exploring
popup
presentation
services
style
types
app_status_manager.go
arrangement.go
background.go
branches_panel.go
command_log_panel.go
commit_files_panel.go
commit_message_panel.go
commits_panel.go
confirmation_panel.go
context.go
context_config.go
controllers.go
custom_patch_options_panel.go
diff_context_size_test.go
diffing.go
dummies.go
editors.go
extras_panel.go
file_watching.go
files_panel.go
filtering.go
filtering_menu_panel.go
global_handlers.go
gui.go
gui_common.go
gui_driver.go
information_panel.go
keybindings.go
layout.go
list_context_config.go
main_panels.go
menu_panel.go
modes.go
options_menu_panel.go
pty.go
pty_windows.go
quitting.go
recent_repos_panel.go
reflog_panel.go
refresh.go
remote_branches_panel.go
remotes_panel.go
searching.go
side_window.go
snake.go
stash_panel.go
status_panel.go
sub_commits_panel.go
submodules_panel.go
suggestions_panel.go
tags_panel.go
tasks_adapter.go
test_mode.go
updates.go
view_helpers.go
views.go
whitespace-toggle.go
window.go
i18n
integration
logs
secureexec
snake
tasks
theme
updates
utils
scripts
test
uffizzi
vendor
.gitignore
.golangci.yml
.goreleaser.yml
CODE-OF-CONDUCT.md
CONTRIBUTING.md
Dockerfile
LICENSE
README.md
go.mod
go.sum
main.go
80 lines
1.9 KiB
Go
80 lines
1.9 KiB
Go
package controllers
|
|
|
|
import (
|
|
"github.com/jesseduffield/lazygit/pkg/gui/types"
|
|
)
|
|
|
|
type CommitMessageController struct {
|
|
baseController
|
|
*controllerCommon
|
|
|
|
getCommitMessage func() string
|
|
onCommitAttempt func(message string)
|
|
onCommitSuccess func()
|
|
}
|
|
|
|
var _ types.IController = &CommitMessageController{}
|
|
|
|
func NewCommitMessageController(
|
|
common *controllerCommon,
|
|
getCommitMessage func() string,
|
|
onCommitAttempt func(message string),
|
|
onCommitSuccess func(),
|
|
) *CommitMessageController {
|
|
return &CommitMessageController{
|
|
baseController: baseController{},
|
|
controllerCommon: common,
|
|
|
|
getCommitMessage: getCommitMessage,
|
|
onCommitAttempt: onCommitAttempt,
|
|
onCommitSuccess: onCommitSuccess,
|
|
}
|
|
}
|
|
|
|
func (self *CommitMessageController) GetKeybindings(opts types.KeybindingsOpts) []*types.Binding {
|
|
bindings := []*types.Binding{
|
|
{
|
|
Key: opts.GetKey(opts.Config.Universal.SubmitEditorText),
|
|
Handler: self.confirm,
|
|
},
|
|
{
|
|
Key: opts.GetKey(opts.Config.Universal.Return),
|
|
Handler: self.close,
|
|
},
|
|
}
|
|
|
|
return bindings
|
|
}
|
|
|
|
func (self *CommitMessageController) Context() types.Context {
|
|
return self.context()
|
|
}
|
|
|
|
// this method is pointless in this context but I'm keeping it consistent
|
|
// with other contexts so that when generics arrive it's easier to refactor
|
|
func (self *CommitMessageController) context() types.Context {
|
|
return self.contexts.CommitMessage
|
|
}
|
|
|
|
func (self *CommitMessageController) confirm() error {
|
|
message := self.getCommitMessage()
|
|
self.onCommitAttempt(message)
|
|
|
|
if message == "" {
|
|
return self.c.ErrorMsg(self.c.Tr.CommitWithoutMessageErr)
|
|
}
|
|
|
|
cmdObj := self.git.Commit.CommitCmdObj(message)
|
|
self.c.LogAction(self.c.Tr.Actions.Commit)
|
|
|
|
_ = self.c.PopContext()
|
|
return self.helpers.GPG.WithGpgHandling(cmdObj, self.c.Tr.CommittingStatus, func() error {
|
|
self.onCommitSuccess()
|
|
return nil
|
|
})
|
|
}
|
|
|
|
func (self *CommitMessageController) close() error {
|
|
return self.c.PopContext()
|
|
}
|