summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Haller <stefan@haller-berlin.de>2024-03-25 15:52:01 +0100
committerStefan Haller <stefan@haller-berlin.de>2024-03-28 13:11:08 +0100
commitde52a68b53a9c74c205d4f785ae6db0c5bb5d26d (patch)
treec6d39bc622742e87ac8dcb4d02d4c76d746f4c8c
parent42ebf1947a1912b210fd3b5c01b5cc0d782e8e89 (diff)
Add a test that demonstrates the problem
Using the "Add to .git/info/exclude" in a worktree results in an error message, as the test shows. The same would happen in a submodule, but I'm not adding an extra test for that, as the circumstances are the same.
-rw-r--r--pkg/integration/tests/test_list.go1
-rw-r--r--pkg/integration/tests/worktree/exclude_file_in_worktree.go46
2 files changed, 47 insertions, 0 deletions
diff --git a/pkg/integration/tests/test_list.go b/pkg/integration/tests/test_list.go
index c5a5b64d6..8f62ca7f5 100644
--- a/pkg/integration/tests/test_list.go
+++ b/pkg/integration/tests/test_list.go
@@ -308,6 +308,7 @@ var tests = []*components.IntegrationTest{
worktree.DetachWorktreeFromBranch,
worktree.DotfileBareRepo,
worktree.DoubleNestedLinkedSubmodule,
+ worktree.ExcludeFileInWorktree,
worktree.FastForwardWorktreeBranch,
worktree.ForceRemoveWorktree,
worktree.RemoveWorktreeFromBranch,
diff --git a/pkg/integration/tests/worktree/exclude_file_in_worktree.go b/pkg/integration/tests/worktree/exclude_file_in_worktree.go
new file mode 100644
index 000000000..60d8d2b32
--- /dev/null
+++ b/pkg/integration/tests/worktree/exclude_file_in_worktree.go
@@ -0,0 +1,46 @@
+package worktree
+
+import (
+ "github.com/jesseduffield/lazygit/pkg/config"
+ . "github.com/jesseduffield/lazygit/pkg/integration/components"
+)
+
+var ExcludeFileInWorktree = NewIntegrationTest(NewIntegrationTestArgs{
+ Description: "Add a file to .git/info/exclude in a worktree",
+ ExtraCmdArgs: []string{},
+ Skip: false,
+ SetupConfig: func(config *config.AppConfig) {},
+ SetupRepo: func(shell *Shell) {
+ shell.EmptyCommit("commit1")
+ shell.AddWorktree("HEAD", "../linked-worktree", "mybranch")
+ shell.CreateFile("../linked-worktree/toExclude", "")
+ },
+ Run: func(t *TestDriver, keys config.KeybindingConfig) {
+ t.Views().Worktrees().
+ Focus().
+ Lines(
+ Contains("repo (main)").IsSelected(),
+ Contains("linked-worktree"),
+ ).
+ SelectNextItem().
+ PressPrimaryAction()
+
+ t.Views().Files().
+ Focus().
+ Lines(
+ Contains("toExclude"),
+ ).
+ Press(keys.Files.IgnoreFile).
+ Tap(func() {
+ t.ExpectPopup().Menu().Title(Equals("Ignore or exclude file")).Select(Contains("Add to .git/info/exclude")).Confirm()
+ }).
+ /* EXPECTED:
+ IsEmpty()
+
+ t.FileSystem().FileContent("../repo/.git/info/exclude", Contains("toExclude"))
+ ACTUAL: */
+ Tap(func() {
+ t.ExpectPopup().Alert().Title(Equals("Error")).Content(Contains("open .git/info/exclude: not a directory"))
+ })
+ },
+})