1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-01-20 05:19:24 +02:00

better logging for stash flow

This commit is contained in:
Jesse Duffield 2022-03-27 17:41:07 +11:00
parent 3e5d4b2c74
commit e011acbab2

View File

@ -559,16 +559,14 @@ func (self *FilesController) createStashMenu() error {
{
DisplayString: self.c.Tr.LcStashAllChanges,
OnPress: func() error {
self.c.LogAction(self.c.Tr.Actions.StashAllChanges)
return self.handleStashSave(self.git.Stash.Save)
return self.handleStashSave(self.git.Stash.Save, self.c.Tr.Actions.StashAllChanges)
},
Key: 's',
},
{
DisplayString: self.c.Tr.LcStashStagedChanges,
OnPress: func() error {
self.c.LogAction(self.c.Tr.Actions.StashStagedChanges)
return self.handleStashSave(self.git.Stash.SaveStagedChanges)
return self.handleStashSave(self.git.Stash.SaveStagedChanges, self.c.Tr.Actions.StashStagedChanges)
},
Key: 'S',
},
@ -577,7 +575,7 @@ func (self *FilesController) createStashMenu() error {
}
func (self *FilesController) stash() error {
return self.handleStashSave(self.git.Stash.Save)
return self.handleStashSave(self.git.Stash.Save, self.c.Tr.Actions.StashAllChanges)
}
func (self *FilesController) createResetToUpstreamMenu() error {
@ -605,7 +603,7 @@ func (self *FilesController) toggleTreeView() error {
return self.c.PostRefreshUpdate(self.context())
}
func (self *FilesController) handleStashSave(stashFunc func(message string) error) error {
func (self *FilesController) handleStashSave(stashFunc func(message string) error, action string) error {
if !self.helpers.WorkingTree.IsWorkingTreeDirty() {
return self.c.ErrorMsg(self.c.Tr.NoTrackedStagedFilesStash)
}
@ -613,6 +611,8 @@ func (self *FilesController) handleStashSave(stashFunc func(message string) erro
return self.c.Prompt(types.PromptOpts{
Title: self.c.Tr.StashChanges,
HandleConfirm: func(stashComment string) error {
self.c.LogAction(action)
if err := stashFunc(stashComment); err != nil {
return self.c.Error(err)
}