From 7ddb80a13eb22f8ce4fb0522397e1db1221f3876 Mon Sep 17 00:00:00 2001 From: Andrew Hynes Date: Fri, 3 Jun 2022 15:41:08 -0230 Subject: [PATCH] feat: add stash option to include untracked changes --- pkg/commands/git_commands/stash.go | 8 ++++++++ pkg/gui/controllers/files_controller.go | 7 +++++++ pkg/i18n/english.go | 4 ++++ 3 files changed, 19 insertions(+) diff --git a/pkg/commands/git_commands/stash.go b/pkg/commands/git_commands/stash.go index c0d187a13..8444032c8 100644 --- a/pkg/commands/git_commands/stash.go +++ b/pkg/commands/git_commands/stash.go @@ -109,3 +109,11 @@ func (self *StashCommands) SaveStagedChanges(message string) error { return nil } + +func (self *StashCommands) StashUntrackedChanges(message string) error { + if err := self.cmd.New("git stash -u").Run(); err != nil { + return err + } + return nil +} + diff --git a/pkg/gui/controllers/files_controller.go b/pkg/gui/controllers/files_controller.go index 8f0b8333f..c7c189542 100644 --- a/pkg/gui/controllers/files_controller.go +++ b/pkg/gui/controllers/files_controller.go @@ -792,6 +792,13 @@ func (self *FilesController) createStashMenu() error { }, Key: 'u', }, + { + Label: self.c.Tr.LcStashIncludeUntrackedChanges, + OnPress: func() error { + return self.handleStashSave(self.git.Stash.StashUntrackedChanges, self.c.Tr.Actions.StashIncludeUntrackedChanges, self.c.Tr.NoFilesToStash) + }, + Key: 'U', + }, }, }) } diff --git a/pkg/i18n/english.go b/pkg/i18n/english.go index 608ad2f45..fe8bf3076 100644 --- a/pkg/i18n/english.go +++ b/pkg/i18n/english.go @@ -293,6 +293,7 @@ type TranslationSet struct { LcStashStagedChanges string LcStashAllChangesKeepIndex string LcStashUnstagedChanges string + LcStashIncludeUntrackedChanges string LcStashOptions string NotARepository string LcJump string @@ -584,6 +585,7 @@ type Actions struct { StashAllChangesKeepIndex string StashStagedChanges string StashUnstagedChanges string + StashIncludeUntrackedChanges string GitFlowFinish string GitFlowStart string CopyToClipboard string @@ -933,6 +935,7 @@ func EnglishTranslationSet() TranslationSet { LcStashStagedChanges: "stash staged changes", LcStashAllChangesKeepIndex: "stash all changes and keep index", LcStashUnstagedChanges: "stash unstaged changes", + LcStashIncludeUntrackedChanges: "stash all changes including untracked files", LcStashOptions: "Stash options", NotARepository: "Error: must be run inside a git repository", LcJump: "jump to panel", @@ -1207,6 +1210,7 @@ func EnglishTranslationSet() TranslationSet { StashAllChangesKeepIndex: "Stash all changes and keep index", StashStagedChanges: "Stash staged changes", StashUnstagedChanges: "Stash unstaged changes", + StashIncludeUntrackedChanges: "Stash all changes including untracked files", GitFlowFinish: "Git flow finish", GitFlowStart: "Git Flow start", CopyToClipboard: "Copy to clipboard",