mirror of
https://github.com/jesseduffield/lazygit.git
synced 2026-09-11 08:06:25 -04:00
The command was renamed from "View worktree options" to "New worktree", but its keybinding config key was still 'worktrees.viewWorktreeOptions'. That name no longer matches the command, and the 'worktrees' section made little sense: it held a single binding that isn't even used in the worktrees panel (that panel uses universal.new), only in the branches, remotes, tags, commits, and stash panels. Other keybinding sections are named after the panel they're local to; this one wasn't local to any. Move it to universal.newWorktree, which describes the action and drops the spurious section, and migrate existing configs automatically. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
53 lines
1.8 KiB
Go
53 lines
1.8 KiB
Go
package worktree
|
|
|
|
import (
|
|
"github.com/jesseduffield/lazygit/pkg/config"
|
|
. "github.com/jesseduffield/lazygit/pkg/integration/components"
|
|
)
|
|
|
|
var LocationCandidates = NewIntegrationTest(NewIntegrationTestArgs{
|
|
Description: "The location menu offers the parents of existing worktrees and the configured default path, and sanitizes the typed name",
|
|
ExtraCmdArgs: []string{},
|
|
Skip: false,
|
|
SetupConfig: func(config *config.AppConfig) {
|
|
config.GetUserConfig().Worktree.DefaultPath = "../config-worktrees"
|
|
},
|
|
SetupRepo: func(shell *Shell) {
|
|
shell.NewBranch("mybranch")
|
|
shell.CreateFileAndAdd("README.md", "hello world")
|
|
shell.Commit("initial commit")
|
|
// a pre-existing linked worktree, so its parent directory is offered as
|
|
// a candidate location alongside the configured default path
|
|
shell.RunCommand([]string{"git", "worktree", "add", "-b", "existing", "../manual-worktrees/existing"})
|
|
},
|
|
Run: func(t *TestDriver, keys config.KeybindingConfig) {
|
|
t.Views().Branches().
|
|
Focus().
|
|
NavigateToLine(Contains("mybranch")).
|
|
Press(keys.Universal.NewWorktree).
|
|
Tap(func() {
|
|
t.ExpectPopup().Menu().
|
|
Title(Equals("New worktree")).
|
|
Select(Contains("New branch and worktree from 'mybranch'")).
|
|
Confirm()
|
|
|
|
// the space is sanitized to a dash so it's a valid branch (and
|
|
// directory) name
|
|
t.ExpectPopup().Prompt().
|
|
Title(Equals("New branch and worktree name")).
|
|
Type("new feature").
|
|
Confirm()
|
|
|
|
// the parent of the existing worktree comes first, then the
|
|
// configured default path; both target the sanitized name
|
|
t.ExpectPopup().Menu().
|
|
Title(Equals("Worktree location")).
|
|
ContainsLines(
|
|
Contains("manual-worktrees").Contains("new-feature"),
|
|
Contains("config-worktrees").Contains("new-feature"),
|
|
).
|
|
Cancel()
|
|
})
|
|
},
|
|
})
|