summaryrefslogtreecommitdiffstats
path: root/pkg
diff options
context:
space:
mode:
authorJesse Duffield <jessedduffield@gmail.com>2019-03-18 21:40:32 +1100
committerJesse Duffield <jessedduffield@gmail.com>2019-03-23 13:26:17 +1100
commitacfc961909a2b21f840358738be4f16d7efa3ca4 (patch)
tree673e46c5a67fc872d5725e295c4371dca3ce62ba /pkg
parentf502f75e1f56bf8f34d3fdf42e934919cd045d85 (diff)
move soft reset keybinding into reset options
Diffstat (limited to 'pkg')
-rw-r--r--pkg/commands/git.go5
-rw-r--r--pkg/gui/files_panel.go22
-rw-r--r--pkg/gui/keybindings.go10
-rw-r--r--pkg/i18n/dutch.go14
-rw-r--r--pkg/i18n/english.go16
-rw-r--r--pkg/i18n/polish.go14
6 files changed, 28 insertions, 53 deletions
diff --git a/pkg/commands/git.go b/pkg/commands/git.go
index dbd9087c2..1b798990c 100644
--- a/pkg/commands/git.go
+++ b/pkg/commands/git.go
@@ -905,3 +905,8 @@ func (c *GitCommand) RemoveUntrackedFiles() error {
func (c *GitCommand) ResetHardHead() error {
return c.OSCommand.RunCommand("git reset --hard HEAD")
}
+
+// ResetSoftHead runs `git reset --soft HEAD`
+func (c *GitCommand) ResetSoftHead() error {
+ return c.OSCommand.RunCommand("git reset --soft HEAD")
+}
diff --git a/pkg/gui/files_panel.go b/pkg/gui/files_panel.go
index 2f91df519..8579e1bb8 100644
--- a/pkg/gui/files_panel.go
+++ b/pkg/gui/files_panel.go
@@ -472,19 +472,6 @@ func (gui *Gui) anyFilesWithMergeConflicts() bool {
return false
}
-func (gui *Gui) handleSoftReset(g *gocui.Gui, v *gocui.View) error {
- return gui.createConfirmationPanel(g, v, gui.Tr.SLocalize("SoftReset"), gui.Tr.SLocalize("ConfirmSoftReset"), func(g *gocui.Gui, v *gocui.View) error {
- if err := gui.GitCommand.SoftReset("HEAD^"); err != nil {
- return gui.createErrorPanel(g, err.Error())
- }
-
- if err := gui.refreshCommits(gui.g); err != nil {
- return err
- }
- return gui.refreshFiles()
- }, nil)
-}
-
type discardOption struct {
handler func(fileName *commands.File) error
description string
@@ -552,7 +539,7 @@ func (gui *Gui) handleCreateDiscardMenu(g *gocui.Gui, v *gocui.View) error {
return gui.createMenu(file.Name, options, handleMenuPress)
}
-func (gui *Gui) handleResetAndClean(g *gocui.Gui, v *gocui.View) error {
+func (gui *Gui) handleCreateResetMenu(g *gocui.Gui, v *gocui.View) error {
options := []*discardAllOption{
{
description: gui.Tr.SLocalize("discardAllChangesToAllFiles"),
@@ -576,6 +563,13 @@ func (gui *Gui) handleResetAndClean(g *gocui.Gui, v *gocui.View) error {
},
},
{
+ description: gui.Tr.SLocalize("softReset"),
+ command: "git reset --soft HEAD",
+ handler: func() error {
+ return gui.GitCommand.ResetSoftHead()
+ },
+ },
+ {
description: gui.Tr.SLocalize("hardReset"),
command: "git reset --hard HEAD",
handler: func() error {
diff --git a/pkg/gui/keybindings.go b/pkg/gui/keybindings.go
index 172e76896..518575550 100644
--- a/pkg/gui/keybindings.go
+++ b/pkg/gui/keybindings.go
@@ -210,12 +210,6 @@ func (gui *Gui) GetInitialKeybindings() []*Binding {
Description: gui.Tr.SLocalize("stashFiles"),
}, {
ViewName: "files",
- Key: 's',
- Modifier: gocui.ModNone,
- Handler: gui.handleSoftReset,
- Description: gui.Tr.SLocalize("softReset"),
- }, {
- ViewName: "files",
Key: 'a',
Modifier: gocui.ModNone,
Handler: gui.handleStageAll,
@@ -230,8 +224,8 @@ func (gui *Gui) GetInitialKeybindings() []*Binding {
ViewName: "files",
Key: 'D',
Modifier: gocui.ModNone,
- Handler: gui.handleResetAndClean,
- Description: gui.Tr.SLocalize("resetHard"),
+ Handler: gui.handleCreateResetMenu,
+ Description: gui.Tr.SLocalize("viewResetOptions"),
}, {
ViewName: "files",
Key: gocui.KeyEnter,
diff --git a/pkg/i18n/dutch.go b/pkg/i18n/dutch.go
index 662c7cce6..8e0f6ce3b 100644
--- a/pkg/i18n/dutch.go
+++ b/pkg/i18n/dutch.go
@@ -389,9 +389,6 @@ func addDutch(i18nObject *i18n.Bundle) error {
ID: "refreshFiles",
Other: `refresh bestanden`,
}, &i18n.Message{
- ID: "resetHard",
- Other: `harde reset and verwijderen ongevolgde bestanden`,
- }, &i18n.Message{
ID: "mergeIntoCurrentBranch",
Other: `merge in met huidige checked out branch`,
}, &i18n.Message{
@@ -471,13 +468,7 @@ func addDutch(i18nObject *i18n.Bundle) error {
Other: "Normal",
}, &i18n.Message{
ID: "softReset",
- Other: "soft reset to last commit",
- }, &i18n.Message{
- ID: "SoftReset",
- Other: "Soft reset",
- }, &i18n.Message{
- ID: "ConfirmSoftReset",
- Other: "Are you sure you want to `reset --soft HEAD^`? The changes in your topmost commit will be placed in your working tree",
+ Other: "soft reset",
}, &i18n.Message{
ID: "CantRebaseOntoSelf",
Other: "You cannot rebase a branch onto itself",
@@ -698,6 +689,9 @@ func addDutch(i18nObject *i18n.Bundle) error {
ID: "discardUntrackedFiles",
Other: "discard untracked files",
}, &i18n.Message{
+ ID: "viewResetOptions",
+ Other: `view reset options`,
+ }, &i18n.Message{
ID: "hardReset",
Other: "hard reset",
},
diff --git a/pkg/i18n/english.go b/pkg/i18n/english.go
index 4e2a6a094..397c262a2 100644
--- a/pkg/i18n/english.go
+++ b/pkg/i18n/english.go
@@ -103,9 +103,6 @@ func addEnglish(i18nObject *i18n.Bundle) error {
ID: "stashFiles",
Other: "stash files",
}, &i18n.Message{
- ID: "softReset",
- Other: "soft reset to last commit",
- }, &i18n.Message{
ID: "open",
Other: "open",
}, &i18n.Message{
@@ -181,11 +178,8 @@ func addEnglish(i18nObject *i18n.Bundle) error {
ID: "FileNoMergeCons",
Other: "This file has no inline merge conflicts",
}, &i18n.Message{
- ID: "SoftReset",
- Other: "Soft reset",
- }, &i18n.Message{
- ID: "ConfirmSoftReset",
- Other: "Are you sure you want to `reset --soft HEAD^`? The changes in your topmost commit will be placed in your working tree",
+ ID: "softReset",
+ Other: "soft reset",
}, &i18n.Message{
ID: "SureTo",
Other: "Are you sure you want to {{.deleteVerb}} {{.fileName}} (you will lose your changes)?",
@@ -454,9 +448,6 @@ func addEnglish(i18nObject *i18n.Bundle) error {
ID: "refreshFiles",
Other: `refresh files`,
}, &i18n.Message{
- ID: "resetHard",
- Other: `reset hard and remove untracked files`,
- }, &i18n.Message{
ID: "mergeIntoCurrentBranch",
Other: `merge into currently checked out branch`,
}, &i18n.Message{
@@ -723,6 +714,9 @@ func addEnglish(i18nObject *i18n.Bundle) error {
}, &i18n.Message{
ID: "hardReset",
Other: "hard reset",
+ }, &i18n.Message{
+ ID: "viewResetOptions",
+ Other: `view reset options`,
},
)
}
diff --git a/pkg/i18n/polish.go b/pkg/i18n/polish.go
index 049c7cefa..e6d09eafb 100644
--- a/pkg/i18n/polish.go
+++ b/pkg/i18n/polish.go
@@ -378,9 +378,6 @@ func addPolish(i18nObject *i18n.Bundle) error {
ID: "refreshFiles",
Other: `odśwież pliki`,
}, &i18n.Message{
- ID: "resetHard",
- Other: `zresetuj twardo i usuń niepotwierdzone pliki`,
- }, &i18n.Message{
ID: "mergeIntoCurrentBranch",
Other: `scal do obecnej gałęzi`,
}, &i18n.Message{
@@ -457,13 +454,7 @@ func addPolish(i18nObject *i18n.Bundle) error {
Other: "Normal",
}, &i18n.Message{
ID: "softReset",
- Other: "soft reset to last commit",
- }, &i18n.Message{
- ID: "SoftReset",
- Other: "Soft reset",
- }, &i18n.Message{
- ID: "ConfirmSoftReset",
- Other: "Are you sure you want to `reset --soft HEAD^`? The changes in your topmost commit will be placed in your working tree",
+ Other: "soft reset",
}, &i18n.Message{
ID: "SureSquashThisCommit",
Other: "Are you sure you want to squash this commit into the commit below?",
@@ -683,6 +674,9 @@ func addPolish(i18nObject *i18n.Bundle) error {
}, &i18n.Message{
ID: "hardReset",
Other: "hard reset",
+ }, &i18n.Message{
+ ID: "viewResetOptions",
+ Other: `view reset options`,
},
)
}