Skip to content

Commit

Permalink
Add test for deep symlink into repo
Browse files Browse the repository at this point in the history
This is a test that covers jesseduffield#3144 and its dupe jesseduffield#3015, where lazygit
is run from a symlink outside of a repo into a subdirectory of that
repo.
  • Loading branch information
jwhitley committed Jan 14, 2024
1 parent cfac030 commit 3232d3b
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 0 deletions.
1 change: 1 addition & 0 deletions pkg/integration/tests/test_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -277,5 +277,6 @@ var tests = []*components.IntegrationTest{
worktree.ForceRemoveWorktree,
worktree.RemoveWorktreeFromBranch,
worktree.ResetWindowTabs,
worktree.SymlinkIntoRepoSubdir,
worktree.WorktreeInRepo,
}
62 changes: 62 additions & 0 deletions pkg/integration/tests/worktree/symlink_into_repo_subdir.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
package worktree

import (
"github.com/jesseduffield/lazygit/pkg/config"
. "github.com/jesseduffield/lazygit/pkg/integration/components"
)

var SymlinkIntoRepoSubdir = NewIntegrationTest(NewIntegrationTestArgs{
Description: "Open lazygit in a symlink into a repo's subdirectory",
ExtraCmdArgs: []string{},
Skip: false,
SetupConfig: func(config *config.AppConfig) {},
SetupRepo: func(shell *Shell) {
// we're going to have a directory structure like this:
// project
// - repo/a/b/c (main worktree with subdirs)
// - link (symlink to repo/a/b/c)
//
shell.CreateFileAndAdd("a/b/c/blah", "blah\n")
shell.Commit("initial commit")
shell.UpdateFile("a/b/c/blah", "updated content\n")

shell.Chdir("..")
shell.RunCommand([]string{"ln", "-s", "repo/a/b/c", "link"})

shell.Chdir("link")
},
Run: func(t *TestDriver, keys config.KeybindingConfig) {
t.Views().Branches().
Lines(
Contains("master"),
)

t.Views().Commits().
Lines(
Contains("initial commit"),
)

t.Views().Files().
IsFocused().
Lines(
Contains(" a/b/c"), // shows as modified
Contains(" M blah"), // shows as modified
).
PressPrimaryAction().
Press(keys.Files.CommitChanges)

t.ExpectPopup().CommitMessagePanel().
Title(Equals("Commit summary")).
Type("Add blah").
Confirm()

t.Views().Files().
IsEmpty()

t.Views().Commits().
Lines(
Contains("Add blah"),
Contains("initial commit"),
)
},
})

0 comments on commit 3232d3b

Please sign in to comment.