summaryrefslogtreecommitdiffstats
path: root/pkg/gui/reflog_panel.go
diff options
context:
space:
mode:
authorJesse Duffield <jessedduffield@gmail.com>2020-03-21 18:45:34 +1100
committerJesse Duffield <jessedduffield@gmail.com>2020-03-25 09:39:04 +1100
commit094939451dd2b15a3593d1a448f7b901500b4cc6 (patch)
tree15fb526e35ba221c46619aabf29daeade9fe59f5 /pkg/gui/reflog_panel.go
parent0e23f44b846b3bd43112c3e0f81f6fbfb45b22e6 (diff)
more explicit env vars
Diffstat (limited to 'pkg/gui/reflog_panel.go')
-rw-r--r--pkg/gui/reflog_panel.go23
1 files changed, 16 insertions, 7 deletions
diff --git a/pkg/gui/reflog_panel.go b/pkg/gui/reflog_panel.go
index 20cba609d..201cf33b1 100644
--- a/pkg/gui/reflog_panel.go
+++ b/pkg/gui/reflog_panel.go
@@ -137,6 +137,8 @@ func (gui *Gui) reflogUndo(g *gocui.Gui, v *gocui.View) error {
startIndex = 0
}
+ envVars := []string{"GIT_REFLOG_ACTION=[lazygit undo]"}
+
reflogActions := []reflogAction{
{
regexStr: `^checkout: moving from ([\S]+)`,
@@ -147,7 +149,7 @@ func (gui *Gui) reflogUndo(g *gocui.Gui, v *gocui.View) error {
return true, gui.handleCheckoutRef(match[1], handleCheckoutRefOptions{
OnDone: onDone,
WaitingStatus: gui.Tr.SLocalize("UndoingStatus"),
- EnvVars: []string{"GIT_REFLOG_ACTION=[lazygit]"},
+ EnvVars: envVars,
},
)
},
@@ -155,7 +157,7 @@ func (gui *Gui) reflogUndo(g *gocui.Gui, v *gocui.View) error {
{
regexStr: `^commit|^rebase -i \(start\)|^reset: moving to|^pull`,
action: func(match []string, commitSha string, onDone func()) (bool, error) {
- return true, gui.handleHardResetWithAutoStash(commitSha, onDone)
+ return true, gui.handleHardResetWithAutoStash(commitSha, handleHardResetWithAutoStashOptions{OnDone: onDone, EnvVars: envVars})
},
},
}
@@ -200,6 +202,8 @@ func (gui *Gui) reflogRedo(g *gocui.Gui, v *gocui.View) error {
return nil
}
+ envVars := []string{"GIT_REFLOG_ACTION=[lazygit redo]"}
+
reflogActions := []reflogAction{
{
regexStr: `^checkout: moving from [\S]+ to ([\S]+)`,
@@ -210,7 +214,7 @@ func (gui *Gui) reflogRedo(g *gocui.Gui, v *gocui.View) error {
return true, gui.handleCheckoutRef(match[1], handleCheckoutRefOptions{
OnDone: onDone,
WaitingStatus: gui.Tr.SLocalize("RedoingStatus"),
- EnvVars: []string{"GIT_REFLOG_ACTION=[lazygit]"},
+ EnvVars: envVars,
},
)
},
@@ -218,7 +222,7 @@ func (gui *Gui) reflogRedo(g *gocui.Gui, v *gocui.View) error {
{
regexStr: `^commit|^rebase -i \(start\)|^reset: moving to|^pull`,
action: func(match []string, commitSha string, onDone func()) (bool, error) {
- return true, gui.handleHardResetWithAutoStash(commitSha, onDone)
+ return true, gui.handleHardResetWithAutoStash(commitSha, handleHardResetWithAutoStashOptions{OnDone: onDone, EnvVars: envVars})
},
},
}
@@ -251,8 +255,13 @@ func (gui *Gui) reflogRedo(g *gocui.Gui, v *gocui.View) error {
return nil
}
+type handleHardResetWithAutoStashOptions struct {
+ OnDone func()
+ EnvVars []string
+}
+
// only to be used in the undo flow for now
-func (gui *Gui) handleHardResetWithAutoStash(commitSha string, onDone func()) error {
+func (gui *Gui) handleHardResetWithAutoStash(commitSha string, options handleHardResetWithAutoStashOptions) error {
// if we have any modified tracked files we need to ask the user if they want us to stash for them
dirtyWorkingTree := false
for _, file := range gui.State.Files {
@@ -263,10 +272,10 @@ func (gui *Gui) handleHardResetWithAutoStash(commitSha string, onDone func()) er
}
reset := func() error {
- if err := gui.resetToRef(commitSha, "hard", commands.RunCommandOptions{EnvVars: []string{"GIT_REFLOG_ACTION=[lazygit]"}}); err != nil {
+ if err := gui.resetToRef(commitSha, "hard", commands.RunCommandOptions{EnvVars: options.EnvVars}); err != nil {
return gui.createErrorPanel(gui.g, err.Error())
}
- onDone()
+ options.OnDone()
return nil
}