Copy a commit message to clipboard: Changes to latest version

This commit is contained in:
nullawhale
2020-10-12 11:13:19 +03:00
committed by Jesse Duffield
parent 031e97ef91
commit 1ff405edd8
6 changed files with 63 additions and 36 deletions

View File

@@ -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)
}

View File

@@ -821,6 +821,13 @@ func (gui *Gui) GetInitialKeybindings() []*Binding {
Handler: gui.wrappedHandler(gui.exitCherryPickingMode),
Description: gui.Tr.LcResetCherryPick,
},
{
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},