diff options
| author | Oleg Pykhalov <go.wigust@gmail.com> | 2019-01-08 22:39:54 +0300 |
|---|---|---|
| committer | Oleg Pykhalov <go.wigust@gmail.com> | 2019-01-08 22:39:54 +0300 |
| commit | e24647701854e6264b7fbe92ea58e6626f3dcdbd (patch) | |
| tree | 682ac10d186f5bf0c5d391b27620623dcc2072bc | |
| parent | Merge pull request #54 from isacikgoz/develop (diff) | |
| download | gitbatch-e24647701854e6264b7fbe92ea58e6626f3dcdbd.tar.gz | |
| -rw-r--r-- | gui/diffview.go | 15 | ||||
| -rw-r--r-- | gui/keybindings.go | 9 |
2 files changed, 24 insertions, 0 deletions
diff --git a/gui/diffview.go b/gui/diffview.go index 9f49456..4bd3590 100644 --- a/gui/diffview.go +++ b/gui/diffview.go @@ -5,6 +5,7 @@ import ( "github.com/isacikgoz/gitbatch/core/command" "github.com/jroimartin/gocui" + "github.com/atotto/clipboard" ) var diffReturnView string @@ -54,6 +55,20 @@ func (gui *Gui) openCommitDiffView(g *gocui.Gui, v *gocui.View) (err error) { return nil } +// copy hash of the selected commit +// called from commitview, so initial view is commitview +func (gui *Gui) copyCommitHash(g *gocui.Gui, v *gocui.View) (err error) { + r := gui.getSelectedRepository() + commit := r.State.Commit + clipboard.WriteAll(commit.Hash) + if err != nil { + if err != gocui.ErrUnknownView { + return err + } + } + return nil +} + // called from status, so initial view may be stagedview or unstaged view func (gui *Gui) openFileDiffView(g *gocui.Gui, v *gocui.View) (err error) { diff --git a/gui/keybindings.go b/gui/keybindings.go index 668fe90..19cb114 100644 --- a/gui/keybindings.go +++ b/gui/keybindings.go @@ -477,6 +477,15 @@ func (gui *Gui) generateKeybindings() error { Description: "Show commit diff", Vital: true, }, + { + View: commitViewFeature.Name, + Key: 'c', + Modifier: gocui.ModNone, + Handler: gui.copyCommitHash, + Display: "c", + Description: "Copy commit hash", + Vital: true, + }, // upstream confirmation { View: confirmationViewFeature.Name, |
