summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Duffield <jessedduffield@gmail.com>2020-02-16 09:03:26 +1100
committerJesse Duffield <jessedduffield@gmail.com>2020-02-16 09:57:49 +1100
commit73d806483747f898bdfc1c7911253cd62092dc42 (patch)
tree93f475d0c63c731b602ba109b61ce327ae8e03ce
parent5b1f60b7eb2b2a73f582b2add0843cc26068bae5 (diff)
allow resetting to branch
-rw-r--r--pkg/gui/branches_panel.go9
-rw-r--r--pkg/gui/keybindings.go8
-rw-r--r--pkg/i18n/english.go3
3 files changed, 20 insertions, 0 deletions
diff --git a/pkg/gui/branches_panel.go b/pkg/gui/branches_panel.go
index 8fa6b83ca..e4e7a432f 100644
--- a/pkg/gui/branches_panel.go
+++ b/pkg/gui/branches_panel.go
@@ -428,3 +428,12 @@ func (gui *Gui) handlePrevBranchesTab(g *gocui.Gui, v *gocui.View) error {
utils.ModuloWithWrap(v.TabIndex-1, len(v.Tabs)),
)
}
+
+func (gui *Gui) handleCreateResetToBranchMenu(g *gocui.Gui, v *gocui.View) error {
+ branch := gui.getSelectedBranch()
+ if branch == nil {
+ return nil
+ }
+
+ return gui.createResetMenu(branch.Name)
+}
diff --git a/pkg/gui/keybindings.go b/pkg/gui/keybindings.go
index b5dc95820..7d79fc3b0 100644
--- a/pkg/gui/keybindings.go
+++ b/pkg/gui/keybindings.go
@@ -539,6 +539,14 @@ func (gui *Gui) GetInitialKeybindings() []*Binding {
},
{
ViewName: "branches",
+ Contexts: []string{"local-branches"},
+ Key: gui.getKey("commits.viewResetOptions"),
+ Modifier: gocui.ModNone,
+ Handler: gui.handleCreateResetToBranchMenu,
+ Description: gui.Tr.SLocalize("resetToThisBranch"),
+ },
+ {
+ ViewName: "branches",
Contexts: []string{"tags"},
Key: gui.getKey("universal.select"),
Modifier: gocui.ModNone,
diff --git a/pkg/i18n/english.go b/pkg/i18n/english.go
index 2d7c40624..c010e2068 100644
--- a/pkg/i18n/english.go
+++ b/pkg/i18n/english.go
@@ -942,6 +942,9 @@ func addEnglish(i18nObject *i18n.Bundle) error {
}, &i18n.Message{
ID: "IgnoreTrackedPrompt",
Other: "Are you sure you want to ignore a tracked file?",
+ }, &i18n.Message{
+ ID: "resetToThisBranch",
+ Other: "reset to the HEAD of this branch",
},
)
}