1
0
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:
Luka Markušić
2022-04-08 11:32:23 +02:00
parent 58ed23a47a
commit 6f7038c827
7 changed files with 34 additions and 11 deletions

View File

@ -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)