diff --git a/pkg/integration/tests/file/exclude_gitignore.go b/pkg/integration/tests/file/exclude_gitignore.go new file mode 100644 index 000000000..7db56d994 --- /dev/null +++ b/pkg/integration/tests/file/exclude_gitignore.go @@ -0,0 +1,39 @@ +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().FileContainsContent(".gitignore", Equals("")) + t.FileSystem().FileContainsContent(".git/info/exclude", DoesNotContain(".gitignore")) + }, +}) diff --git a/pkg/integration/tests/tests.go b/pkg/integration/tests/tests.go index 9278ade2b..da72f84ed 100644 --- a/pkg/integration/tests/tests.go +++ b/pkg/integration/tests/tests.go @@ -54,6 +54,7 @@ var tests = []*components.IntegrationTest{ file.DirWithUntrackedFile, file.DiscardChanges, file.DiscardStagedChanges, + file.ExcludeGitignore, interactive_rebase.AmendMerge, interactive_rebase.One, stash.Rename, diff --git a/test/integration/excludeGitIgnore/expected/repo/.git_keep/COMMIT_EDITMSG b/test/integration/excludeGitIgnore/expected/repo/.git_keep/COMMIT_EDITMSG deleted file mode 100644 index 5852f4463..000000000 --- a/test/integration/excludeGitIgnore/expected/repo/.git_keep/COMMIT_EDITMSG +++ /dev/null @@ -1 +0,0 @@ -Initial commit diff --git a/test/integration/excludeGitIgnore/expected/repo/.git_keep/FETCH_HEAD b/test/integration/excludeGitIgnore/expected/repo/.git_keep/FETCH_HEAD deleted file mode 100644 index e69de29bb..000000000 diff --git a/test/integration/excludeGitIgnore/expected/repo/.git_keep/HEAD b/test/integration/excludeGitIgnore/expected/repo/.git_keep/HEAD deleted file mode 100644 index cb089cd89..000000000 --- a/test/integration/excludeGitIgnore/expected/repo/.git_keep/HEAD +++ /dev/null @@ -1 +0,0 @@ -ref: refs/heads/master diff --git a/test/integration/excludeGitIgnore/expected/repo/.git_keep/config b/test/integration/excludeGitIgnore/expected/repo/.git_keep/config deleted file mode 100644 index 8ae104545..000000000 --- a/test/integration/excludeGitIgnore/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/excludeGitIgnore/expected/repo/.git_keep/description b/test/integration/excludeGitIgnore/expected/repo/.git_keep/description deleted file mode 100644 index 498b267a8..000000000 --- a/test/integration/excludeGitIgnore/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/excludeGitIgnore/expected/repo/.git_keep/index b/test/integration/excludeGitIgnore/expected/repo/.git_keep/index deleted file mode 100644 index 65d675154..000000000 Binary files a/test/integration/excludeGitIgnore/expected/repo/.git_keep/index and /dev/null differ diff --git a/test/integration/excludeGitIgnore/expected/repo/.git_keep/info/exclude b/test/integration/excludeGitIgnore/expected/repo/.git_keep/info/exclude deleted file mode 100644 index 8e9f2071f..000000000 --- a/test/integration/excludeGitIgnore/expected/repo/.git_keep/info/exclude +++ /dev/null @@ -1,7 +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 diff --git a/test/integration/excludeGitIgnore/expected/repo/.git_keep/logs/HEAD b/test/integration/excludeGitIgnore/expected/repo/.git_keep/logs/HEAD deleted file mode 100644 index bad114b22..000000000 --- a/test/integration/excludeGitIgnore/expected/repo/.git_keep/logs/HEAD +++ /dev/null @@ -1 +0,0 @@ -0000000000000000000000000000000000000000 e976bc07c8784964cf239ac9fbdc3535df55269c CI 1657012812 +1000 commit (initial): Initial commit diff --git a/test/integration/excludeGitIgnore/expected/repo/.git_keep/logs/refs/heads/master b/test/integration/excludeGitIgnore/expected/repo/.git_keep/logs/refs/heads/master deleted file mode 100644 index bad114b22..000000000 --- a/test/integration/excludeGitIgnore/expected/repo/.git_keep/logs/refs/heads/master +++ /dev/null @@ -1 +0,0 @@ -0000000000000000000000000000000000000000 e976bc07c8784964cf239ac9fbdc3535df55269c CI 1657012812 +1000 commit (initial): Initial commit diff --git a/test/integration/excludeGitIgnore/expected/repo/.git_keep/objects/4b/825dc642cb6eb9a060e54bf8d69288fbee4904 b/test/integration/excludeGitIgnore/expected/repo/.git_keep/objects/4b/825dc642cb6eb9a060e54bf8d69288fbee4904 deleted file mode 100644 index adf64119a..000000000 Binary files a/test/integration/excludeGitIgnore/expected/repo/.git_keep/objects/4b/825dc642cb6eb9a060e54bf8d69288fbee4904 and /dev/null differ diff --git a/test/integration/excludeGitIgnore/expected/repo/.git_keep/objects/e9/76bc07c8784964cf239ac9fbdc3535df55269c b/test/integration/excludeGitIgnore/expected/repo/.git_keep/objects/e9/76bc07c8784964cf239ac9fbdc3535df55269c deleted file mode 100644 index 9803ebd13..000000000 Binary files a/test/integration/excludeGitIgnore/expected/repo/.git_keep/objects/e9/76bc07c8784964cf239ac9fbdc3535df55269c and /dev/null differ diff --git a/test/integration/excludeGitIgnore/expected/repo/.git_keep/refs/heads/master b/test/integration/excludeGitIgnore/expected/repo/.git_keep/refs/heads/master deleted file mode 100644 index 364cd7031..000000000 --- a/test/integration/excludeGitIgnore/expected/repo/.git_keep/refs/heads/master +++ /dev/null @@ -1 +0,0 @@ -e976bc07c8784964cf239ac9fbdc3535df55269c diff --git a/test/integration/excludeGitIgnore/expected/repo/lg_ignore_file b/test/integration/excludeGitIgnore/expected/repo/lg_ignore_file deleted file mode 100644 index a5bce3fd2..000000000 --- a/test/integration/excludeGitIgnore/expected/repo/lg_ignore_file +++ /dev/null @@ -1 +0,0 @@ -test1 diff --git a/test/integration/excludeGitIgnore/recording.json b/test/integration/excludeGitIgnore/recording.json deleted file mode 100644 index 9c332fe93..000000000 --- a/test/integration/excludeGitIgnore/recording.json +++ /dev/null @@ -1 +0,0 @@ -{"KeyEvents":[{"Timestamp":642,"Mod":0,"Key":256,"Ch":105},{"Timestamp":1529,"Mod":0,"Key":256,"Ch":101},{"Timestamp":2522,"Mod":0,"Key":27,"Ch":0},{"Timestamp":2962,"Mod":0,"Key":256,"Ch":113}],"ResizeEvents":[{"Timestamp":0,"Width":238,"Height":61}]} \ No newline at end of file diff --git a/test/integration/excludeGitIgnore/setup.sh b/test/integration/excludeGitIgnore/setup.sh deleted file mode 100644 index f0c6f3c8f..000000000 --- a/test/integration/excludeGitIgnore/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 > .gitignore - diff --git a/test/integration/excludeGitIgnore/test.json b/test/integration/excludeGitIgnore/test.json deleted file mode 100644 index 9c466ba11..000000000 --- a/test/integration/excludeGitIgnore/test.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "description": "In this test we attempt to add .gitignore to .git/info/exclude to ensure lazygit rejects the action", - "speed": 5 -}