diff options
author | Jesse Duffield <jessedduffield@gmail.com> | 2020-01-09 22:08:28 +1100 |
---|---|---|
committer | Jesse Duffield <jessedduffield@gmail.com> | 2020-01-09 22:36:07 +1100 |
commit | 1b64ea32102185229231907a843ab925146b0595 (patch) | |
tree | 8b9bb16ea3346719ebf4eb47dca7d5e921f4c6af /pkg/gui | |
parent | 9b32e99eb80d3912ecfef3303418e6dce8219a75 (diff) |
add checkout reflog commit keybinding
Diffstat (limited to 'pkg/gui')
-rw-r--r-- | pkg/gui/commits_panel.go | 2 | ||||
-rw-r--r-- | pkg/gui/keybindings.go | 8 | ||||
-rw-r--r-- | pkg/gui/reflog_panel.go | 18 |
3 files changed, 27 insertions, 1 deletions
diff --git a/pkg/gui/commits_panel.go b/pkg/gui/commits_panel.go index 4144d9985..67c126aea 100644 --- a/pkg/gui/commits_panel.go +++ b/pkg/gui/commits_panel.go @@ -612,7 +612,7 @@ func (gui *Gui) handleCreateLightweightTag(commitSha string) error { func (gui *Gui) handleCheckoutCommit(g *gocui.Gui, v *gocui.View) error { commit := gui.getSelectedCommit(g) if commit == nil { - return gui.renderString(g, "main", gui.Tr.SLocalize("NoCommitsThisBranch")) + return nil } return gui.createConfirmationPanel(g, gui.getCommitsView(), true, gui.Tr.SLocalize("checkoutCommit"), gui.Tr.SLocalize("SureCheckoutThisCommit"), func(g *gocui.Gui, v *gocui.View) error { diff --git a/pkg/gui/keybindings.go b/pkg/gui/keybindings.go index 932b01f03..44417ad09 100644 --- a/pkg/gui/keybindings.go +++ b/pkg/gui/keybindings.go @@ -778,6 +778,14 @@ func (gui *Gui) GetInitialKeybindings() []*Binding { Description: gui.Tr.SLocalize("tagCommit"), }, { + ViewName: "commits", + Contexts: []string{"reflog-commits"}, + Key: gui.getKey("universal.select"), + Modifier: gocui.ModNone, + Handler: gui.handleCheckoutReflogCommit, + Description: gui.Tr.SLocalize("checkoutCommit"), + }, + { ViewName: "stash", Key: gui.getKey("universal.select"), Modifier: gocui.ModNone, diff --git a/pkg/gui/reflog_panel.go b/pkg/gui/reflog_panel.go index 968325c56..33577c073 100644 --- a/pkg/gui/reflog_panel.go +++ b/pkg/gui/reflog_panel.go @@ -74,3 +74,21 @@ func (gui *Gui) renderReflogCommitsWithSelection() error { return nil } + +func (gui *Gui) handleCheckoutReflogCommit(g *gocui.Gui, v *gocui.View) error { + commit := gui.getSelectedReflogCommit() + if commit == nil { + return nil + } + + err := gui.createConfirmationPanel(g, gui.getCommitsView(), true, gui.Tr.SLocalize("checkoutCommit"), gui.Tr.SLocalize("SureCheckoutThisCommit"), func(g *gocui.Gui, v *gocui.View) error { + return gui.handleCheckoutRef(commit.Sha) + }, nil) + if err != nil { + return err + } + + gui.State.Panels.ReflogCommits.SelectedLine = 0 + + return nil +} |