Add test for how we show a worktree that is inside the main work tree

We show this with a worktree icon (which is only shown when nerd fonts
are used, so turn these on), but also we strip the trailing `/` that
"git status" reports, so that it shows as a file rather than a directory
with a bogus file in it.

The reason for adding the test is that we are going to touch the logic
that determines whether an item in the Files panel is a linked worktree,
and this guards against regressing.
This commit is contained in:
Stefan Haller
2026-08-15 11:26:58 +02:00
parent 62caf427ac
commit a1f5db6bce
2 changed files with 29 additions and 0 deletions
+1
View File
@@ -557,4 +557,5 @@ var tests = []*components.IntegrationTest{
worktree.SeparateWorkTreeConfig,
worktree.SymlinkIntoRepoSubdir,
worktree.WorktreeInRepo,
worktree.WorktreeInsideRepo,
}
@@ -0,0 +1,28 @@
package worktree
import (
"github.com/jesseduffield/lazygit/pkg/config"
. "github.com/jesseduffield/lazygit/pkg/integration/components"
)
var WorktreeInsideRepo = NewIntegrationTest(NewIntegrationTestArgs{
Description: "A worktree that lives inside the repo's working tree is shown as a single item in the files panel",
ExtraCmdArgs: []string{},
Skip: false,
SetupConfig: func(config *config.AppConfig) {
config.GetUserConfig().Gui.NerdFontsVersion = "3"
},
SetupRepo: func(shell *Shell) {
shell.NewBranch("mybranch")
shell.CreateFileAndAdd("README.md", "hello world")
shell.Commit("initial commit")
shell.AddWorktree("mybranch", "nested-worktree", "newbranch")
},
Run: func(t *TestDriver, keys config.KeybindingConfig) {
t.Views().Files().
IsFocused().
Lines(
Equals("?? 󰌹 nested-worktree").IsSelected(),
)
},
})