From ca191159f514c016f720751ae05d111d8a9d26dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luka=20Marku=C5=A1i=C4=87?= Date: Sun, 8 May 2022 13:30:43 +0200 Subject: [PATCH 1/2] Discard staged changes only --- pkg/commands/git_commands/stash.go | 4 +++ .../controllers/workspace_reset_controller.go | 24 +++++++++++++++- pkg/i18n/english.go | 4 +++ .../expected/repo/.git_keep/COMMIT_EDITMSG | 1 + .../expected/repo/.git_keep/FETCH_HEAD | 0 .../expected/repo/.git_keep/HEAD | 1 + .../expected/repo/.git_keep/ORIG_HEAD | 1 + .../expected/repo/.git_keep/config | 8 ++++++ .../expected/repo/.git_keep/description | 1 + .../expected/repo/.git_keep/index | Bin 0 -> 262 bytes .../expected/repo/.git_keep/info/exclude | 6 ++++ .../expected/repo/.git_keep/logs/HEAD | 5 ++++ .../repo/.git_keep/logs/refs/heads/master | 3 ++ .../02/f629e46dbaa03b58196cced3df07b02c0daf22 | Bin 0 -> 147 bytes .../18/0cf8328022becee9aaa2577a8f84ea2b9f3827 | Bin 0 -> 21 bytes .../1e/3e67b999db1576ad1ee08bf4f02bdf29e49442 | Bin 0 -> 50 bytes .../22/f24c5fcc97c1ff826ecb66b60bdc01937f6052 | 3 ++ .../38/143ad4a0fe2ab6ee53c2ef89a5d9e2bd9535da | Bin 0 -> 21 bytes .../5c/ef9afea6a37d89f925e24ebf71adecb63d1f07 | Bin 0 -> 81 bytes .../5e/2f5743436bdc7602aa3486d5ff294940603c3d | Bin 0 -> 198 bytes .../66/bbc809cdafd867cf9320bfb7484bb8fa898448 | 3 ++ .../9d/b161bba78fbd20e7e4ae004be28e40d747726a | 2 ++ .../9e/7ff93a5c67a0ef098e9e436961746f333edf98 | 2 ++ .../9e/88a70dc8d82dd2afbfd50176ef78e18823bc2c | Bin 0 -> 101 bytes .../a5/bce3fd2565d8f458555a0c6f42d0504a848bd5 | Bin 0 -> 21 bytes .../c7/c7da3c64e86c3270f2639a1379e67e14891b6a | Bin 0 -> 28 bytes .../d0/76cc9cc09acaa2d36fbc7a95fd3e2306494641 | 2 ++ .../e3/18207cf3da045ce47e2632a5326b61030a2c8e | Bin 0 -> 189 bytes .../expected/repo/.git_keep/refs/heads/master | 1 + .../discardStagedFiles/expected/repo/file0 | 1 + .../discardStagedFiles/expected/repo/file1 | 1 + .../discardStagedFiles/expected/repo/file2 | 1 + .../discardStagedFiles/expected/repo/file3 | 1 + .../discardStagedFiles/recording.json | 1 + test/integration/discardStagedFiles/setup.sh | 26 ++++++++++++++++++ test/integration/discardStagedFiles/test.json | 1 + 36 files changed, 102 insertions(+), 1 deletion(-) create mode 100644 test/integration/discardStagedFiles/expected/repo/.git_keep/COMMIT_EDITMSG create mode 100644 test/integration/discardStagedFiles/expected/repo/.git_keep/FETCH_HEAD create mode 100644 test/integration/discardStagedFiles/expected/repo/.git_keep/HEAD create mode 100644 test/integration/discardStagedFiles/expected/repo/.git_keep/ORIG_HEAD create mode 100644 test/integration/discardStagedFiles/expected/repo/.git_keep/config create mode 100644 test/integration/discardStagedFiles/expected/repo/.git_keep/description create mode 100644 test/integration/discardStagedFiles/expected/repo/.git_keep/index create mode 100644 test/integration/discardStagedFiles/expected/repo/.git_keep/info/exclude create mode 100644 test/integration/discardStagedFiles/expected/repo/.git_keep/logs/HEAD create mode 100644 test/integration/discardStagedFiles/expected/repo/.git_keep/logs/refs/heads/master create mode 100644 test/integration/discardStagedFiles/expected/repo/.git_keep/objects/02/f629e46dbaa03b58196cced3df07b02c0daf22 create mode 100644 test/integration/discardStagedFiles/expected/repo/.git_keep/objects/18/0cf8328022becee9aaa2577a8f84ea2b9f3827 create mode 100644 test/integration/discardStagedFiles/expected/repo/.git_keep/objects/1e/3e67b999db1576ad1ee08bf4f02bdf29e49442 create mode 100644 test/integration/discardStagedFiles/expected/repo/.git_keep/objects/22/f24c5fcc97c1ff826ecb66b60bdc01937f6052 create mode 100644 test/integration/discardStagedFiles/expected/repo/.git_keep/objects/38/143ad4a0fe2ab6ee53c2ef89a5d9e2bd9535da create mode 100644 test/integration/discardStagedFiles/expected/repo/.git_keep/objects/5c/ef9afea6a37d89f925e24ebf71adecb63d1f07 create mode 100644 test/integration/discardStagedFiles/expected/repo/.git_keep/objects/5e/2f5743436bdc7602aa3486d5ff294940603c3d create mode 100644 test/integration/discardStagedFiles/expected/repo/.git_keep/objects/66/bbc809cdafd867cf9320bfb7484bb8fa898448 create mode 100644 test/integration/discardStagedFiles/expected/repo/.git_keep/objects/9d/b161bba78fbd20e7e4ae004be28e40d747726a create mode 100644 test/integration/discardStagedFiles/expected/repo/.git_keep/objects/9e/7ff93a5c67a0ef098e9e436961746f333edf98 create mode 100644 test/integration/discardStagedFiles/expected/repo/.git_keep/objects/9e/88a70dc8d82dd2afbfd50176ef78e18823bc2c create mode 100644 test/integration/discardStagedFiles/expected/repo/.git_keep/objects/a5/bce3fd2565d8f458555a0c6f42d0504a848bd5 create mode 100644 test/integration/discardStagedFiles/expected/repo/.git_keep/objects/c7/c7da3c64e86c3270f2639a1379e67e14891b6a create mode 100644 test/integration/discardStagedFiles/expected/repo/.git_keep/objects/d0/76cc9cc09acaa2d36fbc7a95fd3e2306494641 create mode 100644 test/integration/discardStagedFiles/expected/repo/.git_keep/objects/e3/18207cf3da045ce47e2632a5326b61030a2c8e create mode 100644 test/integration/discardStagedFiles/expected/repo/.git_keep/refs/heads/master create mode 100644 test/integration/discardStagedFiles/expected/repo/file0 create mode 100644 test/integration/discardStagedFiles/expected/repo/file1 create mode 100644 test/integration/discardStagedFiles/expected/repo/file2 create mode 100644 test/integration/discardStagedFiles/expected/repo/file3 create mode 100644 test/integration/discardStagedFiles/recording.json create mode 100644 test/integration/discardStagedFiles/setup.sh create mode 100644 test/integration/discardStagedFiles/test.json diff --git a/pkg/commands/git_commands/stash.go b/pkg/commands/git_commands/stash.go index c479d8610..c0d187a13 100644 --- a/pkg/commands/git_commands/stash.go +++ b/pkg/commands/git_commands/stash.go @@ -25,6 +25,10 @@ func NewStashCommands( } } +func (self *StashCommands) DropNewest() error { + return self.cmd.New("git stash drop").Run() +} + func (self *StashCommands) Drop(index int) error { return self.cmd.New(fmt.Sprintf("git stash drop stash@{%d}", index)).Run() } diff --git a/pkg/gui/controllers/workspace_reset_controller.go b/pkg/gui/controllers/workspace_reset_controller.go index dc830b3ba..93277173b 100644 --- a/pkg/gui/controllers/workspace_reset_controller.go +++ b/pkg/gui/controllers/workspace_reset_controller.go @@ -12,7 +12,7 @@ import ( func (self *FilesController) createResetMenu() error { red := style.FgRed - nukeStr := "reset --hard HEAD && git clean -fd" + nukeStr := "git reset --hard HEAD && git clean -fd" if len(self.model.Submodules) > 0 { nukeStr = fmt.Sprintf("%s (%s)", nukeStr, self.c.Tr.LcAndResetSubmodules) } @@ -64,6 +64,28 @@ func (self *FilesController) createResetMenu() error { }, Key: 'c', }, + { + LabelColumns: []string{ + self.c.Tr.LcDiscardStagedChanges, + red.Sprint("stash staged and drop stash"), + }, + Tooltip: "This will create a new stash entry containing only staged files and then drop it.", + OnPress: func() error { + self.c.LogAction(self.c.Tr.Actions.RemoveStagedFiles) + if !self.helpers.WorkingTree.IsWorkingTreeDirty() { + return self.c.ErrorMsg(self.c.Tr.NoTrackedStagedFilesStash) + } + if err := self.git.Stash.SaveStagedChanges("[lazygit] tmp stash"); err != nil { + return self.c.Error(err) + } + if err := self.git.Stash.DropNewest(); err != nil { + return self.c.Error(err) + } + + return self.c.Refresh(types.RefreshOptions{Mode: types.ASYNC, Scope: []types.RefreshableView{types.FILES}}) + }, + Key: 'S', + }, { LabelColumns: []string{ self.c.Tr.LcSoftReset, diff --git a/pkg/i18n/english.go b/pkg/i18n/english.go index 3dd9822e5..4a2f2f7b9 100644 --- a/pkg/i18n/english.go +++ b/pkg/i18n/english.go @@ -265,6 +265,7 @@ type TranslationSet struct { LcDiscardAllChangesToAllFiles string LcDiscardAnyUnstagedChanges string LcDiscardUntrackedFiles string + LcDiscardStagedChanges string LcHardReset string LcViewResetOptions string LcCreateFixupCommit string @@ -594,6 +595,7 @@ type Actions struct { NukeWorkingTree string DiscardUnstagedFileChanges string RemoveUntrackedFiles string + RemoveStagedFiles string SoftReset string MixedReset string HardReset string @@ -883,6 +885,7 @@ func EnglishTranslationSet() TranslationSet { LcDiscardAllChangesToAllFiles: "nuke working tree", LcDiscardAnyUnstagedChanges: "discard unstaged changes", LcDiscardUntrackedFiles: "discard untracked files", + LcDiscardStagedChanges: "discard staged changes", LcHardReset: "hard reset", LcViewResetOptions: `view reset options`, LcCreateFixupCommit: `create fixup commit for this commit`, @@ -1193,6 +1196,7 @@ func EnglishTranslationSet() TranslationSet { NukeWorkingTree: "Nuke working tree", DiscardUnstagedFileChanges: "Discard unstaged file changes", RemoveUntrackedFiles: "Remove untracked files", + RemoveStagedFiles: "Remove staged files", SoftReset: "Soft reset", MixedReset: "Mixed reset", HardReset: "Hard reset", diff --git a/test/integration/discardStagedFiles/expected/repo/.git_keep/COMMIT_EDITMSG b/test/integration/discardStagedFiles/expected/repo/.git_keep/COMMIT_EDITMSG new file mode 100644 index 000000000..6c493ff74 --- /dev/null +++ b/test/integration/discardStagedFiles/expected/repo/.git_keep/COMMIT_EDITMSG @@ -0,0 +1 @@ +file2 diff --git a/test/integration/discardStagedFiles/expected/repo/.git_keep/FETCH_HEAD b/test/integration/discardStagedFiles/expected/repo/.git_keep/FETCH_HEAD new file mode 100644 index 000000000..e69de29bb diff --git a/test/integration/discardStagedFiles/expected/repo/.git_keep/HEAD b/test/integration/discardStagedFiles/expected/repo/.git_keep/HEAD new file mode 100644 index 000000000..cb089cd89 --- /dev/null +++ b/test/integration/discardStagedFiles/expected/repo/.git_keep/HEAD @@ -0,0 +1 @@ +ref: refs/heads/master diff --git a/test/integration/discardStagedFiles/expected/repo/.git_keep/ORIG_HEAD b/test/integration/discardStagedFiles/expected/repo/.git_keep/ORIG_HEAD new file mode 100644 index 000000000..c3e34c41d --- /dev/null +++ b/test/integration/discardStagedFiles/expected/repo/.git_keep/ORIG_HEAD @@ -0,0 +1 @@ +02f629e46dbaa03b58196cced3df07b02c0daf22 diff --git a/test/integration/discardStagedFiles/expected/repo/.git_keep/config b/test/integration/discardStagedFiles/expected/repo/.git_keep/config new file mode 100644 index 000000000..596ebaeb3 --- /dev/null +++ b/test/integration/discardStagedFiles/expected/repo/.git_keep/config @@ -0,0 +1,8 @@ +[core] + repositoryformatversion = 0 + filemode = true + bare = false + logallrefupdates = true +[user] + email = CI@example.com + name = CI diff --git a/test/integration/discardStagedFiles/expected/repo/.git_keep/description b/test/integration/discardStagedFiles/expected/repo/.git_keep/description new file mode 100644 index 000000000..498b267a8 --- /dev/null +++ b/test/integration/discardStagedFiles/expected/repo/.git_keep/description @@ -0,0 +1 @@ +Unnamed repository; edit this file 'description' to name the repository. diff --git a/test/integration/discardStagedFiles/expected/repo/.git_keep/index b/test/integration/discardStagedFiles/expected/repo/.git_keep/index new file mode 100644 index 0000000000000000000000000000000000000000..be47b03227c3338590ec668645dbca0f8610495c GIT binary patch literal 262 zcmZ?q402{*U|<4b=A`nK`lih%Zo+7wm=vS%I$;Ke#w9@M7ZA+AW+7sAWx+qKZSR5) zz3*Il^U>a^rneYa(=u~X4S-tk0gyQeuyoJkzpAM>zC?sZ@#H&Q2=Hp@z6vqN5TOVw z3)LJ6o*zaHO8d^eT(u~?s=wux_IwLi|1=T+Kf^#< literal 0 HcmV?d00001 diff --git a/test/integration/discardStagedFiles/expected/repo/.git_keep/info/exclude b/test/integration/discardStagedFiles/expected/repo/.git_keep/info/exclude new file mode 100644 index 000000000..a5196d1be --- /dev/null +++ b/test/integration/discardStagedFiles/expected/repo/.git_keep/info/exclude @@ -0,0 +1,6 @@ +# git ls-files --others --exclude-from=.git/info/exclude +# Lines that start with '#' are comments. +# For a project mostly in C, the following would be a good set of +# exclude patterns (uncomment them if you want to use them): +# *.[oa] +# *~ diff --git a/test/integration/discardStagedFiles/expected/repo/.git_keep/logs/HEAD b/test/integration/discardStagedFiles/expected/repo/.git_keep/logs/HEAD new file mode 100644 index 000000000..9afe44c14 --- /dev/null +++ b/test/integration/discardStagedFiles/expected/repo/.git_keep/logs/HEAD @@ -0,0 +1,5 @@ +0000000000000000000000000000000000000000 22f24c5fcc97c1ff826ecb66b60bdc01937f6052 CI 1652009263 +0200 commit (initial): file0 +22f24c5fcc97c1ff826ecb66b60bdc01937f6052 9e7ff93a5c67a0ef098e9e436961746f333edf98 CI 1652009263 +0200 commit: file1 +9e7ff93a5c67a0ef098e9e436961746f333edf98 02f629e46dbaa03b58196cced3df07b02c0daf22 CI 1652009263 +0200 commit: file2 +02f629e46dbaa03b58196cced3df07b02c0daf22 02f629e46dbaa03b58196cced3df07b02c0daf22 CI 1652009266 +0200 reset: moving to HEAD +02f629e46dbaa03b58196cced3df07b02c0daf22 02f629e46dbaa03b58196cced3df07b02c0daf22 CI 1652009266 +0200 reset: moving to HEAD diff --git a/test/integration/discardStagedFiles/expected/repo/.git_keep/logs/refs/heads/master b/test/integration/discardStagedFiles/expected/repo/.git_keep/logs/refs/heads/master new file mode 100644 index 000000000..e5e4b05c6 --- /dev/null +++ b/test/integration/discardStagedFiles/expected/repo/.git_keep/logs/refs/heads/master @@ -0,0 +1,3 @@ +0000000000000000000000000000000000000000 22f24c5fcc97c1ff826ecb66b60bdc01937f6052 CI 1652009263 +0200 commit (initial): file0 +22f24c5fcc97c1ff826ecb66b60bdc01937f6052 9e7ff93a5c67a0ef098e9e436961746f333edf98 CI 1652009263 +0200 commit: file1 +9e7ff93a5c67a0ef098e9e436961746f333edf98 02f629e46dbaa03b58196cced3df07b02c0daf22 CI 1652009263 +0200 commit: file2 diff --git a/test/integration/discardStagedFiles/expected/repo/.git_keep/objects/02/f629e46dbaa03b58196cced3df07b02c0daf22 b/test/integration/discardStagedFiles/expected/repo/.git_keep/objects/02/f629e46dbaa03b58196cced3df07b02c0daf22 new file mode 100644 index 0000000000000000000000000000000000000000..5dd10885d211e1167ef8d7849fc3cbb25d8e9983 GIT binary patch literal 147 zcmV;E0Brww0gaA93d0}}0DJZo-U~(7M0cT-LQZ+cMt5l-HX&H(^Xn6O8-_Vd-fLZ( z^#qr8idYgvPOfAu2&Dk)qGfbGMbU)f5g{xYvN`yack6vprNCp3iJhn;6p|rCiarfd zLkLoo(D0|d_R~(Yy-)K~zFdz@Zh5Z{>*EN{5yW7xu9NAuPc`{7H@a>D<_FBGIqQ6K BL~ZE#08nZNMgRZ+ literal 0 HcmV?d00001 diff --git a/test/integration/discardStagedFiles/expected/repo/.git_keep/objects/1e/3e67b999db1576ad1ee08bf4f02bdf29e49442 b/test/integration/discardStagedFiles/expected/repo/.git_keep/objects/1e/3e67b999db1576ad1ee08bf4f02bdf29e49442 new file mode 100644 index 0000000000000000000000000000000000000000..79fcadf67fdecb0f0cffca7ff27b2ae5c031e4d7 GIT binary patch literal 50 zcmV-20L}k+0V^p=O;s>9W-v4`Ff%bxNXyJgHDIt1vAVM0pVqc_!H3>=F1`6^?^M%U I033l4YT~68jQ{`u literal 0 HcmV?d00001 diff --git a/test/integration/discardStagedFiles/expected/repo/.git_keep/objects/22/f24c5fcc97c1ff826ecb66b60bdc01937f6052 b/test/integration/discardStagedFiles/expected/repo/.git_keep/objects/22/f24c5fcc97c1ff826ecb66b60bdc01937f6052 new file mode 100644 index 000000000..f4e1952b1 --- /dev/null +++ b/test/integration/discardStagedFiles/expected/repo/.git_keep/objects/22/f24c5fcc97c1ff826ecb66b60bdc01937f6052 @@ -0,0 +1,3 @@ +x +0=+.&ݦ.=3 )%o>0 ZKYK;২)q!Y1KfSv +Qg§IByyʱ$GǬtN>i37y2+ \ No newline at end of file diff --git a/test/integration/discardStagedFiles/expected/repo/.git_keep/objects/38/143ad4a0fe2ab6ee53c2ef89a5d9e2bd9535da b/test/integration/discardStagedFiles/expected/repo/.git_keep/objects/38/143ad4a0fe2ab6ee53c2ef89a5d9e2bd9535da new file mode 100644 index 0000000000000000000000000000000000000000..06c9cb73d7a8ed6841ce407bd6bb15235c8fa15c GIT binary patch literal 21 ccmb|y2)08mZ`J^%m! literal 0 HcmV?d00001 diff --git a/test/integration/discardStagedFiles/expected/repo/.git_keep/objects/5c/ef9afea6a37d89f925e24ebf71adecb63d1f07 b/test/integration/discardStagedFiles/expected/repo/.git_keep/objects/5c/ef9afea6a37d89f925e24ebf71adecb63d1f07 new file mode 100644 index 0000000000000000000000000000000000000000..6a6f2436255b8a831b87262c4d030c7d63af046b GIT binary patch literal 81 zcmV-X0IvUd0V^p=O;xb8WH2-^Ff%bxNXyJgHDIt1vAVM0pVqc_!H3>=F1`6^?^M%U nND2%Yjvv2elky_RsNhrbEaA#$bt0Y8Sx5?uuqprm;XNz0$Rj03 literal 0 HcmV?d00001 diff --git a/test/integration/discardStagedFiles/expected/repo/.git_keep/objects/5e/2f5743436bdc7602aa3486d5ff294940603c3d b/test/integration/discardStagedFiles/expected/repo/.git_keep/objects/5e/2f5743436bdc7602aa3486d5ff294940603c3d new file mode 100644 index 0000000000000000000000000000000000000000..7aee98aa9a564f30376587951581c8472747d52f GIT binary patch literal 198 zcmV;%06G770gaDAN&`UhpYDPu1Y{rRcb$fKD?sa6O*dQe9U<|H1l#1JE~4*Jnf%L<1hJRXkE{;Bir z;tzS5pJ3!2Atqvmd+clIw4Z4HPknf~!mL~O_wahr@2~fBdxNd%c7os353$Qq*X#;i AWdHyG literal 0 HcmV?d00001 diff --git a/test/integration/discardStagedFiles/expected/repo/.git_keep/objects/66/bbc809cdafd867cf9320bfb7484bb8fa898448 b/test/integration/discardStagedFiles/expected/repo/.git_keep/objects/66/bbc809cdafd867cf9320bfb7484bb8fa898448 new file mode 100644 index 000000000..c84b87a17 --- /dev/null +++ b/test/integration/discardStagedFiles/expected/repo/.git_keep/objects/66/bbc809cdafd867cf9320bfb7484bb8fa898448 @@ -0,0 +1,3 @@ +x+)JMUd040031QHI5`ֶww.hT[H + e"ǨS,gu"YH +$x~5(;rբW-Ж+^ \ No newline at end of file diff --git a/test/integration/discardStagedFiles/expected/repo/.git_keep/objects/9d/b161bba78fbd20e7e4ae004be28e40d747726a b/test/integration/discardStagedFiles/expected/repo/.git_keep/objects/9d/b161bba78fbd20e7e4ae004be28e40d747726a new file mode 100644 index 000000000..c5c3d1d48 --- /dev/null +++ b/test/integration/discardStagedFiles/expected/repo/.git_keep/objects/9d/b161bba78fbd20e7e4ae004be28e40d747726a @@ -0,0 +1,2 @@ +x +0D=+.vn<3 -5o.޽ üŵu,BNǘ}O(YF묈yg3[uZN2sqȄw};'ܧ~BٞzkB!zb#dZۤ97%uYAJ  BP \ No newline at end of file diff --git a/test/integration/discardStagedFiles/expected/repo/.git_keep/objects/9e/7ff93a5c67a0ef098e9e436961746f333edf98 b/test/integration/discardStagedFiles/expected/repo/.git_keep/objects/9e/7ff93a5c67a0ef098e9e436961746f333edf98 new file mode 100644 index 000000000..1c2077cd7 --- /dev/null +++ b/test/integration/discardStagedFiles/expected/repo/.git_keep/objects/9e/7ff93a5c67a0ef098e9e436961746f333edf98 @@ -0,0 +1,2 @@ +xA +0E] 2$"BW=F2D>K."A" p)=F1`6^?^M%U zND2%YmhO4{S2gv2WLwJR>kD literal 0 HcmV?d00001 diff --git a/test/integration/discardStagedFiles/expected/repo/.git_keep/objects/a5/bce3fd2565d8f458555a0c6f42d0504a848bd5 b/test/integration/discardStagedFiles/expected/repo/.git_keep/objects/a5/bce3fd2565d8f458555a0c6f42d0504a848bd5 new file mode 100644 index 0000000000000000000000000000000000000000..285df3e5fbab12262e28d85e78af8a31cd0024c1 GIT binary patch literal 21 ccmb`~^A08nuUMF0Q* literal 0 HcmV?d00001 diff --git a/test/integration/discardStagedFiles/expected/repo/.git_keep/objects/c7/c7da3c64e86c3270f2639a1379e67e14891b6a b/test/integration/discardStagedFiles/expected/repo/.git_keep/objects/c7/c7da3c64e86c3270f2639a1379e67e14891b6a new file mode 100644 index 0000000000000000000000000000000000000000..ee4385f12cb5e2fea6044749c3960a2c40be7b9e GIT binary patch literal 28 kcmb4eAGlPAM9PI~BiJ!N8W-osW20IwDcng9R* literal 0 HcmV?d00001 diff --git a/test/integration/discardStagedFiles/expected/repo/.git_keep/objects/d0/76cc9cc09acaa2d36fbc7a95fd3e2306494641 b/test/integration/discardStagedFiles/expected/repo/.git_keep/objects/d0/76cc9cc09acaa2d36fbc7a95fd3e2306494641 new file mode 100644 index 000000000..2e9066287 --- /dev/null +++ b/test/integration/discardStagedFiles/expected/repo/.git_keep/objects/d0/76cc9cc09acaa2d36fbc7a95fd3e2306494641 @@ -0,0 +1,2 @@ +x+)JMU03c040031QHI5`ֶww.hT[H + yW5Ɨ(| ^-W(x9 \ No newline at end of file diff --git a/test/integration/discardStagedFiles/expected/repo/.git_keep/objects/e3/18207cf3da045ce47e2632a5326b61030a2c8e b/test/integration/discardStagedFiles/expected/repo/.git_keep/objects/e3/18207cf3da045ce47e2632a5326b61030a2c8e new file mode 100644 index 0000000000000000000000000000000000000000..80258c14d84beb0bf8a3919bd3f90707c3ee3540 GIT binary patch literal 189 zcmV;u07CzG0gaEbY6LM11yk==s1F2L>y_6>2!X4%OP5-*WO8u6JvI*H^W*0FbdSeO zF=cP<(t((s`r!^s@tUQ&u*}KUTr(|B(Y2-^=0$n7P%%w+IsDcEsWN4cY$}4YE^EkK zirZ|1Qlx?=mFU4|)4)Mh(puFBJ$V#IjOw&{L`yLxVwvQpf9(gHH+Vg7@BS<8e)X5K rw>Jp95Mm}~c*e1&@s5b@|HP-y?F053H2EIR>Cpi7a&`IxpH@%G6!Br5 literal 0 HcmV?d00001 diff --git a/test/integration/discardStagedFiles/expected/repo/.git_keep/refs/heads/master b/test/integration/discardStagedFiles/expected/repo/.git_keep/refs/heads/master new file mode 100644 index 000000000..c3e34c41d --- /dev/null +++ b/test/integration/discardStagedFiles/expected/repo/.git_keep/refs/heads/master @@ -0,0 +1 @@ +02f629e46dbaa03b58196cced3df07b02c0daf22 diff --git a/test/integration/discardStagedFiles/expected/repo/file0 b/test/integration/discardStagedFiles/expected/repo/file0 new file mode 100644 index 000000000..38143ad4a --- /dev/null +++ b/test/integration/discardStagedFiles/expected/repo/file0 @@ -0,0 +1 @@ +test0 diff --git a/test/integration/discardStagedFiles/expected/repo/file1 b/test/integration/discardStagedFiles/expected/repo/file1 new file mode 100644 index 000000000..a5bce3fd2 --- /dev/null +++ b/test/integration/discardStagedFiles/expected/repo/file1 @@ -0,0 +1 @@ +test1 diff --git a/test/integration/discardStagedFiles/expected/repo/file2 b/test/integration/discardStagedFiles/expected/repo/file2 new file mode 100644 index 000000000..c7c7da3c6 --- /dev/null +++ b/test/integration/discardStagedFiles/expected/repo/file2 @@ -0,0 +1 @@ +hello there diff --git a/test/integration/discardStagedFiles/expected/repo/file3 b/test/integration/discardStagedFiles/expected/repo/file3 new file mode 100644 index 000000000..c7c7da3c6 --- /dev/null +++ b/test/integration/discardStagedFiles/expected/repo/file3 @@ -0,0 +1 @@ +hello there diff --git a/test/integration/discardStagedFiles/recording.json b/test/integration/discardStagedFiles/recording.json new file mode 100644 index 000000000..5abd7e1a8 --- /dev/null +++ b/test/integration/discardStagedFiles/recording.json @@ -0,0 +1 @@ +{"KeyEvents":[{"Timestamp":1175,"Mod":0,"Key":256,"Ch":32},{"Timestamp":1991,"Mod":0,"Key":256,"Ch":68},{"Timestamp":2923,"Mod":0,"Key":256,"Ch":83},{"Timestamp":4453,"Mod":0,"Key":256,"Ch":113}],"ResizeEvents":[{"Timestamp":0,"Width":213,"Height":56}]} \ No newline at end of file diff --git a/test/integration/discardStagedFiles/setup.sh b/test/integration/discardStagedFiles/setup.sh new file mode 100644 index 000000000..caff56b7d --- /dev/null +++ b/test/integration/discardStagedFiles/setup.sh @@ -0,0 +1,26 @@ +#!/bin/sh + +set -e + +cd $1 + +git init + +git config user.email "CI@example.com" +git config user.name "CI" + +echo test0 > file0 +git add . +git commit -am file0 + +echo test1 > file1 +git add . +git commit -am file1 + +echo test2 > file2 +git add . +git commit -am file2 + +echo "hello there" > file1 +echo "hello there" > file2 +echo "hello there" > file3 diff --git a/test/integration/discardStagedFiles/test.json b/test/integration/discardStagedFiles/test.json new file mode 100644 index 000000000..9edc4a815 --- /dev/null +++ b/test/integration/discardStagedFiles/test.json @@ -0,0 +1 @@ +{ "description": "Discarding staged changes", "speed": 5 } From 241d182da7d589e4a30520ff8d9ea4143c9e658a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luka=20Marku=C5=A1i=C4=87?= Date: Sun, 15 May 2022 12:16:20 +0200 Subject: [PATCH 2/2] Make tooltip i18n-able --- pkg/gui/controllers/workspace_reset_controller.go | 2 +- pkg/i18n/english.go | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/pkg/gui/controllers/workspace_reset_controller.go b/pkg/gui/controllers/workspace_reset_controller.go index 93277173b..f34739af7 100644 --- a/pkg/gui/controllers/workspace_reset_controller.go +++ b/pkg/gui/controllers/workspace_reset_controller.go @@ -69,7 +69,7 @@ func (self *FilesController) createResetMenu() error { self.c.Tr.LcDiscardStagedChanges, red.Sprint("stash staged and drop stash"), }, - Tooltip: "This will create a new stash entry containing only staged files and then drop it.", + Tooltip: self.c.Tr.DiscardStagedChangesDescription, OnPress: func() error { self.c.LogAction(self.c.Tr.Actions.RemoveStagedFiles) if !self.helpers.WorkingTree.IsWorkingTreeDirty() { diff --git a/pkg/i18n/english.go b/pkg/i18n/english.go index 4a2f2f7b9..ee14b8193 100644 --- a/pkg/i18n/english.go +++ b/pkg/i18n/english.go @@ -492,6 +492,7 @@ type TranslationSet struct { HardResetAutostashPrompt string UpstreamGone string NukeDescription string + DiscardStagedChangesDescription string Actions Actions Bisect Bisect } @@ -1112,6 +1113,7 @@ func EnglishTranslationSet() TranslationSet { CheckoutPrompt: "Are you sure you want to checkout '%s'?", UpstreamGone: "(upstream gone)", NukeDescription: "If you want to make all the changes in the worktree go away, this is the way to do it. If there are dirty submodule changes this will stash those changes in the submodule(s).", + DiscardStagedChangesDescription: "This will create a new stash entry containing only staged files and then drop it, so that the working tree is left with only unstaged changes", Actions: Actions{ // TODO: combine this with the original keybinding descriptions (those are all in lowercase atm) CheckoutCommit: "Checkout commit",