mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-07-30 03:23:08 +03:00
Add option to stash only unstaged files
This commit is contained in:
@ -561,14 +561,21 @@ func (self *FilesController) createStashMenu() error {
|
||||
OnPress: func() error {
|
||||
return self.handleStashSave(self.git.Stash.Save, self.c.Tr.Actions.StashAllChanges)
|
||||
},
|
||||
Key: 's',
|
||||
Key: 'a',
|
||||
},
|
||||
{
|
||||
DisplayString: self.c.Tr.LcStashStagedChanges,
|
||||
DisplayString: self.c.Tr.LcStashAllChangesKeepIndex,
|
||||
OnPress: func() error {
|
||||
return self.handleStashSave(self.git.Stash.SaveStagedChanges, self.c.Tr.Actions.StashStagedChanges)
|
||||
return self.handleStagedStashSave()
|
||||
},
|
||||
Key: 'S',
|
||||
Key: 'i',
|
||||
},
|
||||
{
|
||||
DisplayString: self.c.Tr.LcStashUnstagedChanges,
|
||||
OnPress: func() error {
|
||||
return self.handleStashSave(self.git.Stash.StashAndKeepIndex, self.c.Tr.Actions.StashUnstagedChanges)
|
||||
},
|
||||
Key: 'u',
|
||||
},
|
||||
},
|
||||
})
|
||||
@ -603,6 +610,14 @@ func (self *FilesController) toggleTreeView() error {
|
||||
return self.c.PostRefreshUpdate(self.context())
|
||||
}
|
||||
|
||||
func (self *FilesController) handleStagedStashSave() error {
|
||||
if !self.helpers.WorkingTree.AnyStagedFiles() {
|
||||
return self.c.ErrorMsg(self.c.Tr.NoTrackedStagedFilesStash)
|
||||
}
|
||||
|
||||
return self.handleStashSave(self.git.Stash.StashAndKeepIndex, self.c.Tr.Actions.StashStagedChanges)
|
||||
}
|
||||
|
||||
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)
|
||||
|
Reference in New Issue
Block a user