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.
This commit is contained in:
Stefan Haller 2024-03-25 15:52:01 +01:00
parent 42ebf1947a
commit de52a68b53
2 changed files with 47 additions and 0 deletions

View file

@ -308,6 +308,7 @@ var tests = []*components.IntegrationTest{
worktree.DetachWorktreeFromBranch,
worktree.DotfileBareRepo,
worktree.DoubleNestedLinkedSubmodule,
worktree.ExcludeFileInWorktree,
worktree.FastForwardWorktreeBranch,
worktree.ForceRemoveWorktree,
worktree.RemoveWorktreeFromBranch,

View file

@ -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"))
})
},
})