mirror of
https://github.com/jesseduffield/lazygit.git
synced 2026-10-12 02:16:50 +00:00
Add a test for opening a file of a branch checked out in another worktree
Pressing `o` on a file in the commit files panel has the same problem as `e` had before the previous commit. If the commit is of a branch that another worktree has checked out, the file is still opened from the current worktree. The absolute path in the panel's copy menu points into the current worktree too. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
51e91fbb85
commit
6c4409b712
@@ -703,6 +703,7 @@ var tests = []*components.IntegrationTest{
|
||||
worktree.LocationCandidates,
|
||||
worktree.NewWorktreePicker,
|
||||
worktree.NewWorktreePickerRemote,
|
||||
worktree.OpenFileOfBranchInOtherWorktree,
|
||||
worktree.RemoveWorktreeAndBothBranches,
|
||||
worktree.RemoveWorktreeAndBranch,
|
||||
worktree.RemoveWorktreeAndDeleteLocalAndRemoteBranch,
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
package worktree
|
||||
|
||||
import (
|
||||
"github.com/jesseduffield/lazygit/pkg/config"
|
||||
. "github.com/jesseduffield/lazygit/pkg/integration/components"
|
||||
)
|
||||
|
||||
var OpenFileOfBranchInOtherWorktree = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
Description: "Open a file of a commit of a branch that is checked out in another worktree, and copy its absolute path",
|
||||
ExtraCmdArgs: []string{},
|
||||
Skip: false,
|
||||
SetupConfig: func(config *config.AppConfig) {
|
||||
config.GetUserConfig().OS.Open = "echo {{filename}} > open-command"
|
||||
config.GetUserConfig().OS.CopyToClipboardCmd = "printf '%s' {{text}} > clipboard"
|
||||
},
|
||||
SetupRepo: func(shell *Shell) {
|
||||
shell.CreateFileAndAdd("README.md", "hello world")
|
||||
shell.Commit("initial commit")
|
||||
shell.NewBranch("mybranch")
|
||||
shell.CreateFileAndAdd("file.txt", "content")
|
||||
shell.Commit("add file")
|
||||
shell.Checkout("master")
|
||||
shell.AddWorktreeCheckout("mybranch", "../linked-worktree")
|
||||
},
|
||||
Run: func(t *TestDriver, keys config.KeybindingConfig) {
|
||||
t.Views().Branches().
|
||||
Focus().
|
||||
Lines(
|
||||
Contains("master").IsSelected(),
|
||||
Contains("mybranch (worktree linked-worktree)"),
|
||||
).
|
||||
NavigateToLine(Contains("mybranch")).
|
||||
PressEnter()
|
||||
|
||||
t.Views().SubCommits().
|
||||
IsFocused().
|
||||
Lines(
|
||||
Contains("add file").IsSelected(),
|
||||
Contains("initial commit"),
|
||||
).
|
||||
PressEnter()
|
||||
|
||||
t.Views().CommitFiles().
|
||||
IsFocused().
|
||||
Lines(
|
||||
Contains("A file.txt").IsSelected(),
|
||||
).
|
||||
Press(keys.Universal.OpenFile).
|
||||
Tap(func() {
|
||||
/* EXPECTED:
|
||||
t.FileSystem().FileContent("open-command", Contains("/linked-worktree/file.txt\n"))
|
||||
ACTUAL: */
|
||||
t.FileSystem().FileContent("open-command", Contains("/repo/file.txt\n"))
|
||||
}).
|
||||
Press(keys.Files.CopyFileInfoToClipboard).
|
||||
Tap(func() {
|
||||
t.ExpectPopup().Menu().
|
||||
Title(Equals("Copy to clipboard")).
|
||||
Select(Contains("Absolute path")).
|
||||
Confirm()
|
||||
|
||||
t.ExpectToast(Equals("File path copied to clipboard"))
|
||||
|
||||
/* EXPECTED:
|
||||
t.FileSystem().FileContent("clipboard", Contains("/linked-worktree/file.txt"))
|
||||
ACTUAL: */
|
||||
t.FileSystem().FileContent("clipboard", Contains("/repo/file.txt"))
|
||||
})
|
||||
},
|
||||
})
|
||||
Reference in New Issue
Block a user