diff options
Diffstat (limited to 'pkg/gui')
-rw-r--r-- | pkg/gui/commits_panel.go | 13 | ||||
-rw-r--r-- | pkg/gui/keybindings.go | 7 |
2 files changed, 20 insertions, 0 deletions
diff --git a/pkg/gui/commits_panel.go b/pkg/gui/commits_panel.go index 10932c1c8..36fa7bd44 100644 --- a/pkg/gui/commits_panel.go +++ b/pkg/gui/commits_panel.go @@ -591,3 +591,16 @@ func (gui *Gui) handleGotoBottomForCommitsPanel(g *gocui.Gui, v *gocui.View) err return nil } + +func (gui *Gui) handleCopySelectedCommitMessageToClipboard() error { + commit := gui.getSelectedLocalCommit() + if commit == nil { + return nil + } + + message, err := gui.GitCommand.GetCommitMessage(commit.Sha) + if err != nil { + return gui.surfaceError(err) + } + return gui.OSCommand.CopyToClipboard(message) +} diff --git a/pkg/gui/keybindings.go b/pkg/gui/keybindings.go index 2093bfca7..ba3e7a509 100644 --- a/pkg/gui/keybindings.go +++ b/pkg/gui/keybindings.go @@ -823,6 +823,13 @@ func (gui *Gui) GetInitialKeybindings() []*Binding { }, { ViewName: "commits", + Contexts: []string{BRANCH_COMMITS_CONTEXT_KEY}, + Key: gui.getKey(config.Commits.CopyCommitMessageToClipboard), + Handler: gui.wrappedHandler(gui.handleCopySelectedCommitMessageToClipboard), + Description: gui.Tr.LcCopyCommitMessageToClipboard, + }, + { + ViewName: "commits", Contexts: []string{REFLOG_COMMITS_CONTEXT_KEY}, Key: gui.getKey(config.Universal.GoInto), Handler: gui.wrappedHandler(gui.handleViewReflogCommitFiles), |