From a30d924afe8e996dd0517bc70855803858efc362 Mon Sep 17 00:00:00 2001 From: Andrew Hynes Date: Thu, 6 Oct 2022 22:53:13 -0230 Subject: test: add test for stash including untracked files --- pkg/integration/tests/stash/stash.go | 2 ++ .../tests/stash/stash_including_untracked_files.go | 33 +++++++++++++++++++++ pkg/integration/tests/tests.go | 1 + .../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 | 12 ++++++++ .../expected/repo/.git_keep/description | 1 + .../expected/repo/.git_keep/index | Bin 0 -> 65 bytes .../expected/repo/.git_keep/info/exclude | 6 ++++ .../expected/repo/.git_keep/logs/HEAD | 2 ++ .../expected/repo/.git_keep/logs/refs/heads/master | 1 + .../expected/repo/.git_keep/logs/refs/stash | 1 + .../18/77c1658e50742642146b3bbb24c6b8635c7b64 | Bin 0 -> 51 bytes .../4b/825dc642cb6eb9a060e54bf8d69288fbee4904 | Bin 0 -> 15 bytes .../6b/584e8ece562ebffc15d38808cd6b98fc3d97ea | Bin 0 -> 22 bytes .../9d/49589525f6c37d177a53a57d82603a22de6076 | Bin 0 -> 170 bytes .../b8/eb39e727d4ac91542d57faa0bea0458c2d30e3 | 2 ++ .../d2/5b2c8a3d20c1b1884fbf1c87aa2014dd99ed7f | Bin 0 -> 122 bytes .../dd/e611c48bd5d6df4157b99f524929851b07eca9 | Bin 0 -> 51 bytes .../f8/528a899ebb020e575e007426baa4535207a214 | 2 ++ .../expected/repo/.git_keep/refs/heads/master | 1 + .../expected/repo/.git_keep/refs/stash | 1 + 24 files changed, 68 insertions(+) create mode 100644 pkg/integration/tests/stash/stash_including_untracked_files.go create mode 100644 test/integration_new/stash/stash_including_untracked_files/expected/repo/.git_keep/COMMIT_EDITMSG create mode 100644 test/integration_new/stash/stash_including_untracked_files/expected/repo/.git_keep/FETCH_HEAD create mode 100644 test/integration_new/stash/stash_including_untracked_files/expected/repo/.git_keep/HEAD create mode 100644 test/integration_new/stash/stash_including_untracked_files/expected/repo/.git_keep/ORIG_HEAD create mode 100644 test/integration_new/stash/stash_including_untracked_files/expected/repo/.git_keep/config create mode 100644 test/integration_new/stash/stash_including_untracked_files/expected/repo/.git_keep/description create mode 100644 test/integration_new/stash/stash_including_untracked_files/expected/repo/.git_keep/index create mode 100644 test/integration_new/stash/stash_including_untracked_files/expected/repo/.git_keep/info/exclude create mode 100644 test/integration_new/stash/stash_including_untracked_files/expected/repo/.git_keep/logs/HEAD create mode 100644 test/integration_new/stash/stash_including_untracked_files/expected/repo/.git_keep/logs/refs/heads/master create mode 100644 test/integration_new/stash/stash_including_untracked_files/expected/repo/.git_keep/logs/refs/stash create mode 100644 test/integration_new/stash/stash_including_untracked_files/expected/repo/.git_keep/objects/18/77c1658e50742642146b3bbb24c6b8635c7b64 create mode 100644 test/integration_new/stash/stash_including_untracked_files/expected/repo/.git_keep/objects/4b/825dc642cb6eb9a060e54bf8d69288fbee4904 create mode 100644 test/integration_new/stash/stash_including_untracked_files/expected/repo/.git_keep/objects/6b/584e8ece562ebffc15d38808cd6b98fc3d97ea create mode 100644 test/integration_new/stash/stash_including_untracked_files/expected/repo/.git_keep/objects/9d/49589525f6c37d177a53a57d82603a22de6076 create mode 100644 test/integration_new/stash/stash_including_untracked_files/expected/repo/.git_keep/objects/b8/eb39e727d4ac91542d57faa0bea0458c2d30e3 create mode 100644 test/integration_new/stash/stash_including_untracked_files/expected/repo/.git_keep/objects/d2/5b2c8a3d20c1b1884fbf1c87aa2014dd99ed7f create mode 100644 test/integration_new/stash/stash_including_untracked_files/expected/repo/.git_keep/objects/dd/e611c48bd5d6df4157b99f524929851b07eca9 create mode 100644 test/integration_new/stash/stash_including_untracked_files/expected/repo/.git_keep/objects/f8/528a899ebb020e575e007426baa4535207a214 create mode 100644 test/integration_new/stash/stash_including_untracked_files/expected/repo/.git_keep/refs/heads/master create mode 100644 test/integration_new/stash/stash_including_untracked_files/expected/repo/.git_keep/refs/stash diff --git a/pkg/integration/tests/stash/stash.go b/pkg/integration/tests/stash/stash.go index db9e13b78..af247550b 100644 --- a/pkg/integration/tests/stash/stash.go +++ b/pkg/integration/tests/stash/stash.go @@ -17,6 +17,7 @@ var Stash = NewIntegrationTest(NewIntegrationTestArgs{ }, Run: func(shell *Shell, input *Input, assert *Assert, keys config.KeybindingConfig) { assert.StashCount(0) + assert.WorkingTreeFileCount(1) input.PressKeys(keys.Files.ViewStashOptions) assert.InMenu() @@ -26,5 +27,6 @@ var Stash = NewIntegrationTest(NewIntegrationTestArgs{ input.Confirm() assert.StashCount(1) + assert.WorkingTreeFileCount(0) }, }) diff --git a/pkg/integration/tests/stash/stash_including_untracked_files.go b/pkg/integration/tests/stash/stash_including_untracked_files.go new file mode 100644 index 000000000..4ed7957ac --- /dev/null +++ b/pkg/integration/tests/stash/stash_including_untracked_files.go @@ -0,0 +1,33 @@ +package stash + +import ( + "github.com/jesseduffield/lazygit/pkg/config" + . "github.com/jesseduffield/lazygit/pkg/integration/components" +) + +var StashIncludingUntrackedFiles = NewIntegrationTest(NewIntegrationTestArgs{ + Description: "Stashing all files including untracked ones", + ExtraCmdArgs: "", + Skip: false, + SetupConfig: func(config *config.AppConfig) {}, + SetupRepo: func(shell *Shell) { + shell.EmptyCommit("initial commit") + shell.CreateFile("file_1", "content") + shell.CreateFile("file_2", "content") + shell.GitAdd("file_1") + }, + Run: func(shell *Shell, input *Input, assert *Assert, keys config.KeybindingConfig) { + assert.StashCount(0) + assert.WorkingTreeFileCount(2) + + input.PressKeys(keys.Files.ViewStashOptions) + assert.InMenu() + + input.PressKeys("U") + input.Type("stash name") + input.Confirm() + + assert.StashCount(1) + assert.WorkingTreeFileCount(0) + }, +}) diff --git a/pkg/integration/tests/tests.go b/pkg/integration/tests/tests.go index fd42f0ed6..028e990ee 100644 --- a/pkg/integration/tests/tests.go +++ b/pkg/integration/tests/tests.go @@ -29,6 +29,7 @@ var tests = []*components.IntegrationTest{ custom_commands.MultiplePrompts, custom_commands.MenuFromCommand, stash.Stash, + stash.StashIncludingUntrackedFiles, } func GetTests() []*components.IntegrationTest { diff --git a/test/integration_new/stash/stash_including_untracked_files/expected/repo/.git_keep/COMMIT_EDITMSG b/test/integration_new/stash/stash_including_untracked_files/expected/repo/.git_keep/COMMIT_EDITMSG new file mode 100644 index 000000000..802607664 --- /dev/null +++ b/test/integration_new/stash/stash_including_untracked_files/expected/repo/.git_keep/COMMIT_EDITMSG @@ -0,0 +1 @@ +initial commit diff --git a/test/integration_new/stash/stash_including_untracked_files/expected/repo/.git_keep/FETCH_HEAD b/test/integration_new/stash/stash_including_untracked_files/expected/repo/.git_keep/FETCH_HEAD new file mode 100644 index 000000000..e69de29bb diff --git a/test/integration_new/stash/stash_including_untracked_files/expected/repo/.git_keep/HEAD b/test/integration_new/stash/stash_including_untracked_files/expected/repo/.git_keep/HEAD new file mode 100644 index 000000000..cb089cd89 --- /dev/null +++ b/test/integration_new/stash/stash_including_untracked_files/expected/repo/.git_keep/HEAD @@ -0,0 +1 @@ +ref: refs/heads/master diff --git a/test/integration_new/stash/stash_including_untracked_files/expected/repo/.git_keep/ORIG_HEAD b/test/integration_new/stash/stash_including_untracked_files/expected/repo/.git_keep/ORIG_HEAD new file mode 100644 index 000000000..4ee40e25d --- /dev/null +++ b/test/integration_new/stash/stash_including_untracked_files/expected/repo/.git_keep/ORIG_HEAD @@ -0,0 +1 @@ +d25b2c8a3d20c1b1884fbf1c87aa2014dd99ed7f diff --git a/test/integration_new/stash/stash_including_untracked_files/expected/repo/.git_keep/config b/test/integration_new/stash/stash_including_untracked_files/expected/repo/.git_keep/config new file mode 100644 index 000000000..8a748ce32 --- /dev/null +++ b/test/integration_new/stash/stash_including_untracked_files/expected/repo/.git_keep/config @@ -0,0 +1,12 @@ +[core] + repositoryformatversion = 0 + filemode = true + bare = false + logallrefupdates = true + ignorecase = true + precomposeunicode = true +[user] + email = CI@example.com + name = CI +[commit] + gpgSign = false diff --git a/test/integration_new/stash/stash_including_untracked_files/expected/repo/.git_keep/description b/test/integration_new/stash/stash_including_untracked_files/expected/repo/.git_keep/description new file mode 100644 index 000000000..498b267a8 --- /dev/null +++ b/test/integration_new/stash/stash_including_untracked_files/expected/repo/.git_keep/description @@ -0,0 +1 @@ +Unnamed repository; edit this file 'description' to name the repository. diff --git a/test/integration_new/stash/stash_including_untracked_files/expected/repo/.git_keep/index b/test/integration_new/stash/stash_including_untracked_files/expected/repo/.git_keep/index new file mode 100644 index 000000000..65d675154 Binary files /dev/null and b/test/integration_new/stash/stash_including_untracked_files/expected/repo/.git_keep/index differ diff --git a/test/integration_new/stash/stash_including_untracked_files/expected/repo/.git_keep/info/exclude b/test/integration_new/stash/stash_including_untracked_files/expected/repo/.git_keep/info/exclude new file mode 100644 index 000000000..a5196d1be --- /dev/null +++ b/test/integration_new/stash/stash_including_untracked_files/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_new/stash/stash_including_untracked_files/expected/repo/.git_keep/logs/HEAD b/test/integration_new/stash/stash_including_untracked_files/expected/repo/.git_keep/logs/HEAD new file mode 100644 index 000000000..e8dcfb6d1 --- /dev/null +++ b/test/integration_new/stash/stash_including_untracked_files/expected/repo/.git_keep/logs/HEAD @@ -0,0 +1,2 @@ +0000000000000000000000000000000000000000 d25b2c8a3d20c1b1884fbf1c87aa2014dd99ed7f CI 1665105632 -0230 commit (initial): initial commit +d25b2c8a3d20c1b1884fbf1c87aa2014dd99ed7f d25b2c8a3d20c1b1884fbf1c87aa2014dd99ed7f CI 1665105633 -0230 reset: moving to HEAD diff --git a/test/integration_new/stash/stash_including_untracked_files/expected/repo/.git_keep/logs/refs/heads/master b/test/integration_new/stash/stash_including_untracked_files/expected/repo/.git_keep/logs/refs/heads/master new file mode 100644 index 000000000..df042a3dd --- /dev/null +++ b/test/integration_new/stash/stash_including_untracked_files/expected/repo/.git_keep/logs/refs/heads/master @@ -0,0 +1 @@ +0000000000000000000000000000000000000000 d25b2c8a3d20c1b1884fbf1c87aa2014dd99ed7f CI 1665105632 -0230 commit (initial): initial commit diff --git a/test/integration_new/stash/stash_including_untracked_files/expected/repo/.git_keep/logs/refs/stash b/test/integration_new/stash/stash_including_untracked_files/expected/repo/.git_keep/logs/refs/stash new file mode 100644 index 000000000..335d6aab8 --- /dev/null +++ b/test/integration_new/stash/stash_including_untracked_files/expected/repo/.git_keep/logs/refs/stash @@ -0,0 +1 @@ +0000000000000000000000000000000000000000 b8eb39e727d4ac91542d57faa0bea0458c2d30e3 CI 1665105633 -0230 On master: stash name diff --git a/test/integration_new/stash/stash_including_untracked_files/expected/repo/.git_keep/objects/18/77c1658e50742642146b3bbb24c6b8635c7b64 b/test/integration_new/stash/stash_including_untracked_files/expected/repo/.git_keep/objects/18/77c1658e50742642146b3bbb24c6b8635c7b64 new file mode 100644 index 000000000..c5ff32d89 Binary files /dev/null and b/test/integration_new/stash/stash_including_untracked_files/expected/repo/.git_keep/objects/18/77c1658e50742642146b3bbb24c6b8635c7b64 differ diff --git a/test/integration_new/stash/stash_including_untracked_files/expected/repo/.git_keep/objects/4b/825dc642cb6eb9a060e54bf8d69288fbee4904 b/test/integration_new/stash/stash_including_untracked_files/expected/repo/.git_keep/objects/4b/825dc642cb6eb9a060e54bf8d69288fbee4904 new file mode 100644 index 000000000..adf64119a Binary files /dev/null and b/test/integration_new/stash/stash_including_untracked_files/expected/repo/.git_keep/objects/4b/825dc642cb6eb9a060e54bf8d69288fbee4904 differ diff --git a/test/integration_new/stash/stash_including_untracked_files/expected/repo/.git_keep/objects/6b/584e8ece562ebffc15d38808cd6b98fc3d97ea b/test/integration_new/stash/stash_including_untracked_files/expected/repo/.git_keep/objects/6b/584e8ece562ebffc15d38808cd6b98fc3d97ea new file mode 100644 index 000000000..ec9764eae Binary files /dev/null and b/test/integration_new/stash/stash_including_untracked_files/expected/repo/.git_keep/objects/6b/584e8ece562ebffc15d38808cd6b98fc3d97ea differ diff --git a/test/integration_new/stash/stash_including_untracked_files/expected/repo/.git_keep/objects/9d/49589525f6c37d177a53a57d82603a22de6076 b/test/integration_new/stash/stash_including_untracked_files/expected/repo/.git_keep/objects/9d/49589525f6c37d177a53a57d82603a22de6076 new file mode 100644 index 000000000..99fe3e9e5 Binary files /dev/null and b/test/integration_new/stash/stash_including_untracked_files/expected/repo/.git_keep/objects/9d/49589525f6c37d177a53a57d82603a22de6076 differ diff --git a/test/integration_new/stash/stash_including_untracked_files/expected/repo/.git_keep/objects/b8/eb39e727d4ac91542d57faa0bea0458c2d30e3 b/test/integration_new/stash/stash_including_untracked_files/expected/repo/.git_keep/objects/b8/eb39e727d4ac91542d57faa0bea0458c2d30e3 new file mode 100644 index 000000000..eb6b19046 --- /dev/null +++ b/test/integration_new/stash/stash_including_untracked_files/expected/repo/.git_keep/objects/b8/eb39e727d4ac91542d57faa0bea0458c2d30e3 @@ -0,0 +1,2 @@ +xMJ1`}\@#"¬f* +#;Ƿ7wx׶1nT-"F9R:S(T2cdMr锸R╠aŜC[N"TK1M዆¹0q'ŔpL Ň)K>Kj*3A°ϼm\a2Ҷ0FF{yz?!_1帹UY` \ No newline at end of file diff --git a/test/integration_new/stash/stash_including_untracked_files/expected/repo/.git_keep/objects/d2/5b2c8a3d20c1b1884fbf1c87aa2014dd99ed7f b/test/integration_new/stash/stash_including_untracked_files/expected/repo/.git_keep/objects/d2/5b2c8a3d20c1b1884fbf1c87aa2014dd99ed7f new file mode 100644 index 000000000..d412fdb69 Binary files /dev/null and b/test/integration_new/stash/stash_including_untracked_files/expected/repo/.git_keep/objects/d2/5b2c8a3d20c1b1884fbf1c87aa2014dd99ed7f differ diff --git a/test/integration_new/stash/stash_including_untracked_files/expected/repo/.git_keep/objects/dd/e611c48bd5d6df4157b99f524929851b07eca9 b/test/integration_new/stash/stash_including_untracked_files/expected/repo/.git_keep/objects/dd/e611c48bd5d6df4157b99f524929851b07eca9 new file mode 100644 index 000000000..1721a0ff4 Binary files /dev/null and b/test/integration_new/stash/stash_including_untracked_files/expected/repo/.git_keep/objects/dd/e611c48bd5d6df4157b99f524929851b07eca9 differ diff --git a/test/integration_new/stash/stash_including_untracked_files/expected/repo/.git_keep/objects/f8/528a899ebb020e575e007426baa4535207a214 b/test/integration_new/stash/stash_including_untracked_files/expected/repo/.git_keep/objects/f8/528a899ebb020e575e007426baa4535207a214 new file mode 100644 index 000000000..8cc3c848b --- /dev/null +++ b/test/integration_new/stash/stash_including_untracked_files/expected/repo/.git_keep/objects/f8/528a899ebb020e575e007426baa4535207a214 @@ -0,0 +1,2 @@ +x] +0})J~7A}16o 6 |C@pjsޓBIo5Z,&RҖ04|B+ўuqajBtJ:4R)zOcm[ PW(q+%M[ : \ No newline at end of file diff --git a/test/integration_new/stash/stash_including_untracked_files/expected/repo/.git_keep/refs/heads/master b/test/integration_new/stash/stash_including_untracked_files/expected/repo/.git_keep/refs/heads/master new file mode 100644 index 000000000..4ee40e25d --- /dev/null +++ b/test/integration_new/stash/stash_including_untracked_files/expected/repo/.git_keep/refs/heads/master @@ -0,0 +1 @@ +d25b2c8a3d20c1b1884fbf1c87aa2014dd99ed7f diff --git a/test/integration_new/stash/stash_including_untracked_files/expected/repo/.git_keep/refs/stash b/test/integration_new/stash/stash_including_untracked_files/expected/repo/.git_keep/refs/stash new file mode 100644 index 000000000..3e0f2a550 --- /dev/null +++ b/test/integration_new/stash/stash_including_untracked_files/expected/repo/.git_keep/refs/stash @@ -0,0 +1 @@ +b8eb39e727d4ac91542d57faa0bea0458c2d30e3 -- cgit v1.2.3