From 8a1c7639426c2ceee562674adde85dd9a5b46127 Mon Sep 17 00:00:00 2001 From: Jesse Duffield Date: Wed, 28 Dec 2022 17:15:59 +1100 Subject: [PATCH] more git ignore stuff in integration test --- .../tests/file/exclude_gitignore.go | 39 ----------- pkg/integration/tests/file/gitignore.go | 63 ++++++++++++++++++ pkg/integration/tests/tests.go | 2 +- .../expected/repo/.git_keep/COMMIT_EDITMSG | 1 - .../expected/repo/.git_keep/FETCH_HEAD | 0 .../excludeMenu/expected/repo/.git_keep/HEAD | 1 - .../expected/repo/.git_keep/config | 10 --- .../expected/repo/.git_keep/description | 1 - .../excludeMenu/expected/repo/.git_keep/index | Bin 65 -> 0 bytes .../expected/repo/.git_keep/info/exclude | 9 --- .../expected/repo/.git_keep/logs/HEAD | 1 - .../repo/.git_keep/logs/refs/heads/master | 1 - .../12/9cdae0c4ccd050e8398bcb18b2ce1e4a5626f9 | Bin 123 -> 0 bytes .../4b/825dc642cb6eb9a060e54bf8d69288fbee4904 | Bin 15 -> 0 bytes .../expected/repo/.git_keep/refs/heads/master | 1 - .../excludeMenu/expected/repo/myfile1 | 1 - test/integration/excludeMenu/recording.json | 1 - test/integration/excludeMenu/setup.sh | 15 ----- test/integration/excludeMenu/test.json | 4 -- 19 files changed, 64 insertions(+), 86 deletions(-) delete mode 100644 pkg/integration/tests/file/exclude_gitignore.go create mode 100644 pkg/integration/tests/file/gitignore.go delete mode 100644 test/integration/excludeMenu/expected/repo/.git_keep/COMMIT_EDITMSG delete mode 100644 test/integration/excludeMenu/expected/repo/.git_keep/FETCH_HEAD delete mode 100644 test/integration/excludeMenu/expected/repo/.git_keep/HEAD delete mode 100644 test/integration/excludeMenu/expected/repo/.git_keep/config delete mode 100644 test/integration/excludeMenu/expected/repo/.git_keep/description delete mode 100644 test/integration/excludeMenu/expected/repo/.git_keep/index delete mode 100644 test/integration/excludeMenu/expected/repo/.git_keep/info/exclude delete mode 100644 test/integration/excludeMenu/expected/repo/.git_keep/logs/HEAD delete mode 100644 test/integration/excludeMenu/expected/repo/.git_keep/logs/refs/heads/master delete mode 100644 test/integration/excludeMenu/expected/repo/.git_keep/objects/12/9cdae0c4ccd050e8398bcb18b2ce1e4a5626f9 delete mode 100644 test/integration/excludeMenu/expected/repo/.git_keep/objects/4b/825dc642cb6eb9a060e54bf8d69288fbee4904 delete mode 100644 test/integration/excludeMenu/expected/repo/.git_keep/refs/heads/master delete mode 100644 test/integration/excludeMenu/expected/repo/myfile1 delete mode 100644 test/integration/excludeMenu/recording.json delete mode 100644 test/integration/excludeMenu/setup.sh delete mode 100644 test/integration/excludeMenu/test.json diff --git a/pkg/integration/tests/file/exclude_gitignore.go b/pkg/integration/tests/file/exclude_gitignore.go deleted file mode 100644 index 10ea62f15..000000000 --- a/pkg/integration/tests/file/exclude_gitignore.go +++ /dev/null @@ -1,39 +0,0 @@ -package file - -import ( - "github.com/jesseduffield/lazygit/pkg/config" - . "github.com/jesseduffield/lazygit/pkg/integration/components" -) - -var ExcludeGitignore = NewIntegrationTest(NewIntegrationTestArgs{ - Description: "Failed attempt at excluding and ignoring the .gitignore file", - ExtraCmdArgs: "", - Skip: false, - SetupConfig: func(config *config.AppConfig) { - }, - SetupRepo: func(shell *Shell) { - shell.CreateFile(".gitignore", "") - }, - Run: func(t *TestDriver, keys config.KeybindingConfig) { - t.Views().Files(). - IsFocused(). - Lines( - Contains(`?? .gitignore`).IsSelected(), - ). - Press(keys.Files.IgnoreFile). - Tap(func() { - t.ExpectPopup().Menu().Title(Equals("ignore or exclude file")).Select(Contains("add to .git/info/exclude")).Confirm() - - t.ExpectPopup().Alert().Title(Equals("Error")).Content(Equals("Cannot exclude .gitignore")).Confirm() - }). - Press(keys.Files.IgnoreFile). - Tap(func() { - t.ExpectPopup().Menu().Title(Equals("ignore or exclude file")).Select(Contains("add to .gitignore")).Confirm() - - t.ExpectPopup().Alert().Title(Equals("Error")).Content(Equals("Cannot ignore .gitignore")).Confirm() - }) - - t.FileSystem().FileContent(".gitignore", Equals("")) - t.FileSystem().FileContent(".git/info/exclude", DoesNotContain(".gitignore")) - }, -}) diff --git a/pkg/integration/tests/file/gitignore.go b/pkg/integration/tests/file/gitignore.go new file mode 100644 index 000000000..eca835e82 --- /dev/null +++ b/pkg/integration/tests/file/gitignore.go @@ -0,0 +1,63 @@ +package file + +import ( + "github.com/jesseduffield/lazygit/pkg/config" + . "github.com/jesseduffield/lazygit/pkg/integration/components" +) + +var GitIgnore = NewIntegrationTest(NewIntegrationTestArgs{ + Description: "Verify that we can't ignore the .gitignore file, then ignore/exclude other files", + ExtraCmdArgs: "", + Skip: false, + SetupConfig: func(config *config.AppConfig) { + }, + SetupRepo: func(shell *Shell) { + shell.CreateFile(".gitignore", "") + shell.CreateFile("toExclude", "") + shell.CreateFile("toIgnore", "") + }, + Run: func(t *TestDriver, keys config.KeybindingConfig) { + t.Views().Files(). + IsFocused(). + Lines( + Contains(`?? .gitignore`).IsSelected(), + Contains(`?? toExclude`), + Contains(`?? toIgnore`), + ). + Press(keys.Files.IgnoreFile). + // ensure we can't exclude the .gitignore file + Tap(func() { + t.ExpectPopup().Menu().Title(Equals("ignore or exclude file")).Select(Contains("add to .git/info/exclude")).Confirm() + + t.ExpectPopup().Alert().Title(Equals("Error")).Content(Equals("Cannot exclude .gitignore")).Confirm() + }). + Press(keys.Files.IgnoreFile). + // ensure we can't ignore the .gitignore file + Tap(func() { + t.ExpectPopup().Menu().Title(Equals("ignore or exclude file")).Select(Contains("add to .gitignore")).Confirm() + + t.ExpectPopup().Alert().Title(Equals("Error")).Content(Equals("Cannot ignore .gitignore")).Confirm() + + t.FileSystem().FileContent(".gitignore", Equals("")) + t.FileSystem().FileContent(".git/info/exclude", DoesNotContain(".gitignore")) + }). + SelectNextItem(). + Press(keys.Files.IgnoreFile). + // exclude a file + Tap(func() { + t.ExpectPopup().Menu().Title(Equals("ignore or exclude file")).Select(Contains("add to .git/info/exclude")).Confirm() + + t.FileSystem().FileContent(".gitignore", Equals("")) + t.FileSystem().FileContent(".git/info/exclude", Contains("toExclude")) + }). + SelectNextItem(). + Press(keys.Files.IgnoreFile). + // ignore a file + Tap(func() { + t.ExpectPopup().Menu().Title(Equals("ignore or exclude file")).Select(Contains("add to .gitignore")).Confirm() + + t.FileSystem().FileContent(".gitignore", Equals("toIgnore\n")) + t.FileSystem().FileContent(".git/info/exclude", Contains("toExclude")) + }) + }, +}) diff --git a/pkg/integration/tests/tests.go b/pkg/integration/tests/tests.go index da72f84ed..da101e06b 100644 --- a/pkg/integration/tests/tests.go +++ b/pkg/integration/tests/tests.go @@ -54,7 +54,7 @@ var tests = []*components.IntegrationTest{ file.DirWithUntrackedFile, file.DiscardChanges, file.DiscardStagedChanges, - file.ExcludeGitignore, + file.GitIgnore, interactive_rebase.AmendMerge, interactive_rebase.One, stash.Rename, diff --git a/test/integration/excludeMenu/expected/repo/.git_keep/COMMIT_EDITMSG b/test/integration/excludeMenu/expected/repo/.git_keep/COMMIT_EDITMSG deleted file mode 100644 index 5852f4463..000000000 --- a/test/integration/excludeMenu/expected/repo/.git_keep/COMMIT_EDITMSG +++ /dev/null @@ -1 +0,0 @@ -Initial commit diff --git a/test/integration/excludeMenu/expected/repo/.git_keep/FETCH_HEAD b/test/integration/excludeMenu/expected/repo/.git_keep/FETCH_HEAD deleted file mode 100644 index e69de29bb..000000000 diff --git a/test/integration/excludeMenu/expected/repo/.git_keep/HEAD b/test/integration/excludeMenu/expected/repo/.git_keep/HEAD deleted file mode 100644 index cb089cd89..000000000 --- a/test/integration/excludeMenu/expected/repo/.git_keep/HEAD +++ /dev/null @@ -1 +0,0 @@ -ref: refs/heads/master diff --git a/test/integration/excludeMenu/expected/repo/.git_keep/config b/test/integration/excludeMenu/expected/repo/.git_keep/config deleted file mode 100644 index 8ae104545..000000000 --- a/test/integration/excludeMenu/expected/repo/.git_keep/config +++ /dev/null @@ -1,10 +0,0 @@ -[core] - repositoryformatversion = 0 - filemode = true - bare = false - logallrefupdates = true - ignorecase = true - precomposeunicode = true -[user] - email = CI@example.com - name = CI diff --git a/test/integration/excludeMenu/expected/repo/.git_keep/description b/test/integration/excludeMenu/expected/repo/.git_keep/description deleted file mode 100644 index 498b267a8..000000000 --- a/test/integration/excludeMenu/expected/repo/.git_keep/description +++ /dev/null @@ -1 +0,0 @@ -Unnamed repository; edit this file 'description' to name the repository. diff --git a/test/integration/excludeMenu/expected/repo/.git_keep/index b/test/integration/excludeMenu/expected/repo/.git_keep/index deleted file mode 100644 index 65d675154f23ffb2d0196e017d44a5e7017550f5..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 65 zcmZ?q402{*U|<4bhL9jvS0E+HV4z^Y<=qr}%;|LA&IJiiy? 1657012793 +1000 commit (initial): Initial commit diff --git a/test/integration/excludeMenu/expected/repo/.git_keep/logs/refs/heads/master b/test/integration/excludeMenu/expected/repo/.git_keep/logs/refs/heads/master deleted file mode 100644 index d4002669d..000000000 --- a/test/integration/excludeMenu/expected/repo/.git_keep/logs/refs/heads/master +++ /dev/null @@ -1 +0,0 @@ -0000000000000000000000000000000000000000 129cdae0c4ccd050e8398bcb18b2ce1e4a5626f9 CI 1657012793 +1000 commit (initial): Initial commit diff --git a/test/integration/excludeMenu/expected/repo/.git_keep/objects/12/9cdae0c4ccd050e8398bcb18b2ce1e4a5626f9 b/test/integration/excludeMenu/expected/repo/.git_keep/objects/12/9cdae0c4ccd050e8398bcb18b2ce1e4a5626f9 deleted file mode 100644 index ffa5ec6527c917d3d2ef3b94fd6ec4876aa8087a..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 123 zcmV->0EGW|0ga783d0}}0DJZodoPsLtVW@fLQXzI&4voGmav6Bzkz%p*I|Y!y|pT! z?QoHe87O;W=i^O&n4%t#({Op49e#y)fkW~80t8XwxxKHuPztlb}-%4)}(9Vvi d%@_u_YD82!-6z5)brs)LYFgpw)E{~lFONt5Jcs}Q diff --git a/test/integration/excludeMenu/expected/repo/.git_keep/objects/4b/825dc642cb6eb9a060e54bf8d69288fbee4904 b/test/integration/excludeMenu/expected/repo/.git_keep/objects/4b/825dc642cb6eb9a060e54bf8d69288fbee4904 deleted file mode 100644 index adf64119a33d7621aeeaa505d30adb58afaa5559..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 15 Wcmb myfile1 - diff --git a/test/integration/excludeMenu/test.json b/test/integration/excludeMenu/test.json deleted file mode 100644 index b2ef1f3f4..000000000 --- a/test/integration/excludeMenu/test.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "description": "In this test a file is added to .git/info/exclude using the ignore or exclude menu", - "speed": 5 -} \ No newline at end of file