diff options
author | Luka Markušić <luka.markusic@microblink.com> | 2022-04-08 11:32:23 +0200 |
---|---|---|
committer | Luka Markušić <luka.markusic@microblink.com> | 2022-04-10 09:35:59 +0200 |
commit | 6f7038c8277f82c32d2c23502f94fdf675ad07e1 (patch) | |
tree | bd91c9fab2ec10f613d93360df04df08065c6eef /pkg/gui/controllers/files_controller.go | |
parent | 58ed23a47adbc4e0cef119c0f32adceaef28ff48 (diff) |
Add option to stash only unstaged files
Diffstat (limited to 'pkg/gui/controllers/files_controller.go')
-rw-r--r-- | pkg/gui/controllers/files_controller.go | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/pkg/gui/controllers/files_controller.go b/pkg/gui/controllers/files_controller.go index 764c9753b..e37cc0951 100644 --- a/pkg/gui/controllers/files_controller.go +++ b/pkg/gui/controllers/files_controller.go @@ -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) |