From de52a68b53a9c74c205d4f785ae6db0c5bb5d26d Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Mon, 25 Mar 2024 15:52:01 +0100 Subject: [PATCH] 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. --- pkg/integration/tests/test_list.go | 1 + .../worktree/exclude_file_in_worktree.go | 46 +++++++++++++++++++ 2 files changed, 47 insertions(+) create mode 100644 pkg/integration/tests/worktree/exclude_file_in_worktree.go 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")) + }) + }, +})