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 65d675154..000000000 Binary files a/test/integration/excludeMenu/expected/repo/.git_keep/index and /dev/null differ diff --git a/test/integration/excludeMenu/expected/repo/.git_keep/info/exclude b/test/integration/excludeMenu/expected/repo/.git_keep/info/exclude deleted file mode 100644 index f5a9a36c0..000000000 --- a/test/integration/excludeMenu/expected/repo/.git_keep/info/exclude +++ /dev/null @@ -1,9 +0,0 @@ -# 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] -# *~ -.DS_Store - -myfile1 \ No newline at end of file diff --git a/test/integration/excludeMenu/expected/repo/.git_keep/logs/HEAD b/test/integration/excludeMenu/expected/repo/.git_keep/logs/HEAD deleted file mode 100644 index d4002669d..000000000 --- a/test/integration/excludeMenu/expected/repo/.git_keep/logs/HEAD +++ /dev/null @@ -1 +0,0 @@ -0000000000000000000000000000000000000000 129cdae0c4ccd050e8398bcb18b2ce1e4a5626f9 CI 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 ffa5ec652..000000000 Binary files a/test/integration/excludeMenu/expected/repo/.git_keep/objects/12/9cdae0c4ccd050e8398bcb18b2ce1e4a5626f9 and /dev/null differ 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 adf64119a..000000000 Binary files a/test/integration/excludeMenu/expected/repo/.git_keep/objects/4b/825dc642cb6eb9a060e54bf8d69288fbee4904 and /dev/null differ diff --git a/test/integration/excludeMenu/expected/repo/.git_keep/refs/heads/master b/test/integration/excludeMenu/expected/repo/.git_keep/refs/heads/master deleted file mode 100644 index d255339cd..000000000 --- a/test/integration/excludeMenu/expected/repo/.git_keep/refs/heads/master +++ /dev/null @@ -1 +0,0 @@ -129cdae0c4ccd050e8398bcb18b2ce1e4a5626f9 diff --git a/test/integration/excludeMenu/expected/repo/myfile1 b/test/integration/excludeMenu/expected/repo/myfile1 deleted file mode 100644 index a5bce3fd2..000000000 --- a/test/integration/excludeMenu/expected/repo/myfile1 +++ /dev/null @@ -1 +0,0 @@ -test1 diff --git a/test/integration/excludeMenu/recording.json b/test/integration/excludeMenu/recording.json deleted file mode 100644 index d45736788..000000000 --- a/test/integration/excludeMenu/recording.json +++ /dev/null @@ -1 +0,0 @@ -{"KeyEvents":[{"Timestamp":788,"Mod":0,"Key":256,"Ch":105},{"Timestamp":2342,"Mod":0,"Key":256,"Ch":101},{"Timestamp":3429,"Mod":0,"Key":256,"Ch":113}],"ResizeEvents":[{"Timestamp":0,"Width":238,"Height":61}]} \ No newline at end of file diff --git a/test/integration/excludeMenu/setup.sh b/test/integration/excludeMenu/setup.sh deleted file mode 100644 index bd74671ea..000000000 --- a/test/integration/excludeMenu/setup.sh +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/sh - -set -e - -cd $1 - -git init - -git config user.email "CI@example.com" -git config user.name "CI" - -git commit --allow-empty -m "Initial commit" - -echo test1 > 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