From 5b9331f42c6b077f865f4b1d12e5cfe7601755f0 Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Sun, 5 Oct 2025 14:23:05 +0200 Subject: [PATCH] Rename AddFileInWorktree to AddFileInWorktreeOrSubmodule It works for submodules too. Also, pass file name and file content explicitly; the existing tests don't care about these, but when writing tests that do, it makes them easier to understand. --- pkg/integration/components/shell.go | 6 +++--- pkg/integration/tests/worktree/force_remove_worktree.go | 2 +- .../tests/worktree/remove_worktree_from_branch.go | 2 +- pkg/integration/tests/worktree/reset_window_tabs.go | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/pkg/integration/components/shell.go b/pkg/integration/components/shell.go index 4c833f2ab..faa6fff13 100644 --- a/pkg/integration/components/shell.go +++ b/pkg/integration/components/shell.go @@ -428,11 +428,11 @@ func (self *Shell) AddWorktreeCheckout(base string, path string) *Shell { }) } -func (self *Shell) AddFileInWorktree(worktreePath string) *Shell { - self.CreateFile(filepath.Join(worktreePath, "content"), "content") +func (self *Shell) AddFileInWorktreeOrSubmodule(worktreePath string, filePath string, content string) *Shell { + self.CreateFile(filepath.Join(worktreePath, filePath), content) self.RunCommand([]string{ - "git", "-C", worktreePath, "add", "content", + "git", "-C", worktreePath, "add", filePath, }) return self diff --git a/pkg/integration/tests/worktree/force_remove_worktree.go b/pkg/integration/tests/worktree/force_remove_worktree.go index 23d0b9a88..0d3bf90cf 100644 --- a/pkg/integration/tests/worktree/force_remove_worktree.go +++ b/pkg/integration/tests/worktree/force_remove_worktree.go @@ -17,7 +17,7 @@ var ForceRemoveWorktree = NewIntegrationTest(NewIntegrationTestArgs{ shell.EmptyCommit("commit 2") shell.EmptyCommit("commit 3") shell.AddWorktree("mybranch", "../linked-worktree", "newbranch") - shell.AddFileInWorktree("../linked-worktree") + shell.AddFileInWorktreeOrSubmodule("../linked-worktree", "file", "content") }, Run: func(t *TestDriver, keys config.KeybindingConfig) { t.Views().Worktrees(). diff --git a/pkg/integration/tests/worktree/remove_worktree_from_branch.go b/pkg/integration/tests/worktree/remove_worktree_from_branch.go index 7ef9d0ae9..f0b8de4e6 100644 --- a/pkg/integration/tests/worktree/remove_worktree_from_branch.go +++ b/pkg/integration/tests/worktree/remove_worktree_from_branch.go @@ -17,7 +17,7 @@ var RemoveWorktreeFromBranch = NewIntegrationTest(NewIntegrationTestArgs{ shell.EmptyCommit("commit 2") shell.EmptyCommit("commit 3") shell.AddWorktree("mybranch", "../linked-worktree", "newbranch") - shell.AddFileInWorktree("../linked-worktree") + shell.AddFileInWorktreeOrSubmodule("../linked-worktree", "file", "content") }, Run: func(t *TestDriver, keys config.KeybindingConfig) { t.Views().Branches(). diff --git a/pkg/integration/tests/worktree/reset_window_tabs.go b/pkg/integration/tests/worktree/reset_window_tabs.go index c24373be8..12c4526eb 100644 --- a/pkg/integration/tests/worktree/reset_window_tabs.go +++ b/pkg/integration/tests/worktree/reset_window_tabs.go @@ -24,7 +24,7 @@ var ResetWindowTabs = NewIntegrationTest(NewIntegrationTestArgs{ shell.EmptyCommit("commit 2") shell.EmptyCommit("commit 3") shell.AddWorktree("mybranch", "../linked-worktree", "newbranch") - shell.AddFileInWorktree("../linked-worktree") + shell.AddFileInWorktreeOrSubmodule("../linked-worktree", "file", "content") }, Run: func(t *TestDriver, keys config.KeybindingConfig) { // focus the remotes tab i.e. the second tab in the branches window