Skip to content

Commit

Permalink
warnings for stash actions
Browse files Browse the repository at this point in the history
  • Loading branch information
jesseduffield committed Apr 20, 2020
1 parent 68586ec commit f05a5e5
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 2 deletions.
1 change: 1 addition & 0 deletions docs/Config.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ Default path for the config file:
show: true
mouseEvents: true
skipUnstageLineWarning: false
skipStashWarning: true
git:
paging:
colorArg: always
Expand Down
1 change: 1 addition & 0 deletions pkg/config/app_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@ func GetDefaultConfig() []byte {
scrollPastBottom: true
mouseEvents: true
skipUnstageLineWarning: false
skipStashWarning: true
sidePanelWidth: 0.3333
theme:
lightTheme: false
Expand Down
32 changes: 30 additions & 2 deletions pkg/gui/stash_panel.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,39 @@ func (gui *Gui) refreshStashEntries(g *gocui.Gui) error {
// specific functions

func (gui *Gui) handleStashApply(g *gocui.Gui, v *gocui.View) error {
return gui.stashDo(g, v, "apply")
skipStashWarning := gui.Config.GetUserConfig().GetBool("gui.skipStashWarning")

apply := func() error {
return gui.stashDo(g, v, "apply")
}

if skipStashWarning {
return apply()
}

title := gui.Tr.SLocalize("StashApply")
message := gui.Tr.SLocalize("SureApplyStashEntry")
return gui.createConfirmationPanel(g, v, true, title, message, func(g *gocui.Gui, v *gocui.View) error {
return apply()
}, nil)
}

func (gui *Gui) handleStashPop(g *gocui.Gui, v *gocui.View) error {
return gui.stashDo(g, v, "pop")
skipStashWarning := gui.Config.GetUserConfig().GetBool("gui.skipStashWarning")

pop := func() error {
return gui.stashDo(g, v, "pop")
}

if skipStashWarning {
return pop()
}

title := gui.Tr.SLocalize("StashPop")
message := gui.Tr.SLocalize("SurePopStashEntry")
return gui.createConfirmationPanel(g, v, true, title, message, func(g *gocui.Gui, v *gocui.View) error {
return pop()
}, nil)
}

func (gui *Gui) handleStashDrop(g *gocui.Gui, v *gocui.View) error {
Expand Down
12 changes: 12 additions & 0 deletions pkg/i18n/english.go
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,18 @@ func addEnglish(i18nObject *i18n.Bundle) error {
}, &i18n.Message{
ID: "SureDropStashEntry",
Other: "Are you sure you want to drop this stash entry?",
}, &i18n.Message{
ID: "StashPop",
Other: "Stash pop",
}, &i18n.Message{
ID: "SurePopStashEntry",
Other: "Are you sure you want to pop this stash entry?",
}, &i18n.Message{
ID: "StashApply",
Other: "Stash apply",
}, &i18n.Message{
ID: "SureApplyStashEntry",
Other: "Are you sure you want to apply this stash entry?",
}, &i18n.Message{
ID: "NoStashTo",
Other: "No stash to {{.method}}",
Expand Down

0 comments on commit f05a5e5

Please sign in to comment.