Skip to content

Commit

Permalink
Showing 3 changed files with 27 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pkg/gui/commits_panel.go
Original file line number Diff line number Diff line change
@@ -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 {
8 changes: 8 additions & 0 deletions pkg/gui/keybindings.go
Original file line number Diff line number Diff line change
@@ -777,6 +777,14 @@ func (gui *Gui) GetInitialKeybindings() []*Binding {
Handler: gui.handleTagCommit,
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"),
18 changes: 18 additions & 0 deletions pkg/gui/reflog_panel.go
Original file line number Diff line number Diff line change
@@ -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
}

0 comments on commit 1b64ea3

Please sign in to comment.