Skip to content

Commit

Permalink
clean as well as reset (I'm hoping this is a good design decision)
Browse files Browse the repository at this point in the history
  • Loading branch information
jesseduffield committed Dec 5, 2018
1 parent 66512ca commit 3b51d7c
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 12 deletions.
10 changes: 7 additions & 3 deletions pkg/commands/git.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,9 +208,13 @@ func includesInt(list []int, a int) bool {
return false
}

// ResetHard clears the working tree to match HEAD
func (c *GitCommand) ResetHard() error {
return c.OSCommand.RunCommand("git reset --hard HEAD")
// ResetAndClean removes all unstaged changes and removes all untracked files
func (c *GitCommand) ResetAndClean() error {
if err := c.OSCommand.RunCommand("git reset --hard HEAD"); err != nil {
return err
}

return c.OSCommand.RunCommand("git clean -fd")
}

// UpstreamDifferenceCount checks how many pushables/pullables there are for the
Expand Down
4 changes: 2 additions & 2 deletions pkg/gui/files_panel.go
Original file line number Diff line number Diff line change
Expand Up @@ -433,9 +433,9 @@ func (gui *Gui) handleAbortMerge(g *gocui.Gui, v *gocui.View) error {
return gui.refreshFiles(g)
}

func (gui *Gui) handleResetHard(g *gocui.Gui, v *gocui.View) error {
func (gui *Gui) handleResetAndClean(g *gocui.Gui, v *gocui.View) error {
return gui.createConfirmationPanel(g, v, gui.Tr.SLocalize("ClearFilePanel"), gui.Tr.SLocalize("SureResetHardHead"), func(g *gocui.Gui, v *gocui.View) error {
if err := gui.GitCommand.ResetHard(); err != nil {
if err := gui.GitCommand.ResetAndClean(); err != nil {
gui.createErrorPanel(g, err.Error())
}
return gui.refreshFiles(g)
Expand Down
2 changes: 1 addition & 1 deletion pkg/gui/keybindings.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ func (gui *Gui) GetKeybindings() []*Binding {
ViewName: "files",
Key: 'D',
Modifier: gocui.ModNone,
Handler: gui.handleResetHard,
Handler: gui.handleResetAndClean,
Description: gui.Tr.SLocalize("resetHard"),
}, {
ViewName: "files",
Expand Down
4 changes: 2 additions & 2 deletions pkg/i18n/dutch.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ func addDutch(i18nObject *i18n.Bundle) error {
Other: "Dit bestand heeft geen merge conflicten",
}, &i18n.Message{
ID: "SureResetHardHead",
Other: "Weet je het zeker dat je `reset --hard HEAD` wil uitvoeren? Het kan dat je hierdoor bestanden verliest",
Other: "Weet je het zeker dat je `reset --hard HEAD` en `clean -fd` wil uitvoeren? Het kan dat je hierdoor bestanden verliest",
}, &i18n.Message{
ID: "SureTo",
Other: "Weet je het zeker dat je {{.fileName}} wilt {{.deleteVerb}} (je veranderingen zullen worden verwijderd)",
Expand Down Expand Up @@ -384,7 +384,7 @@ func addDutch(i18nObject *i18n.Bundle) error {
Other: `refresh bestanden`,
}, &i18n.Message{
ID: "resetHard",
Other: `harde reset`,
Other: `harde reset and verwijderen ongevolgde bestanden`,
}, &i18n.Message{
ID: "mergeIntoCurrentBranch",
Other: `merge in met huidige checked out branch`,
Expand Down
4 changes: 2 additions & 2 deletions pkg/i18n/english.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ func addEnglish(i18nObject *i18n.Bundle) error {
Other: "This file has no merge conflicts",
}, &i18n.Message{
ID: "SureResetHardHead",
Other: "Are you sure you want `reset --hard HEAD`? You may lose changes",
Other: "Are you sure you want `reset --hard HEAD` and `clean -fd`? You may lose changes",
}, &i18n.Message{
ID: "SureTo",
Other: "Are you sure you want to {{.deleteVerb}} {{.fileName}} (you will lose your changes)?",
Expand Down Expand Up @@ -392,7 +392,7 @@ func addEnglish(i18nObject *i18n.Bundle) error {
Other: `refresh files`,
}, &i18n.Message{
ID: "resetHard",
Other: `reset hard`,
Other: `reset hard and remove untracked files`,
}, &i18n.Message{
ID: "mergeIntoCurrentBranch",
Other: `merge into currently checked out branch`,
Expand Down
4 changes: 2 additions & 2 deletions pkg/i18n/polish.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ func addPolish(i18nObject *i18n.Bundle) error {
Other: "Ten plik nie powoduje konfliktów scalania",
}, &i18n.Message{
ID: "SureResetHardHead",
Other: "Jesteś pewny, że chcesz wykonać `reset --hard HEAD`? Możesz stracić wprowadzone zmiany",
Other: "Jesteś pewny, że chcesz wykonać `reset --hard HEAD` i `clean -fd`? Możesz stracić wprowadzone zmiany",
}, &i18n.Message{
ID: "SureTo",
Other: "Jesteś pewny, że chcesz {{.deleteVerb}} {{.fileName}} (stracisz swoje wprowadzone zmiany)?",
Expand Down Expand Up @@ -370,7 +370,7 @@ func addPolish(i18nObject *i18n.Bundle) error {
Other: `odśwież pliki`,
}, &i18n.Message{
ID: "resetHard",
Other: `zresetuj twardo`,
Other: `zresetuj twardo i usuń niepotwierdzone pliki`,
}, &i18n.Message{
ID: "mergeIntoCurrentBranch",
Other: `scal do obecnej gałęzi`,
Expand Down

0 comments on commit 3b51d7c

Please sign in to comment.