mirror of
https://github.com/jesseduffield/lazygit.git
synced 2026-09-10 23:56:24 -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>
69 lines
2.1 KiB
Go
69 lines
2.1 KiB
Go
package worktree
|
|
|
|
import (
|
|
"github.com/jesseduffield/lazygit/pkg/config"
|
|
. "github.com/jesseduffield/lazygit/pkg/integration/components"
|
|
)
|
|
|
|
var AddFromBranch = NewIntegrationTest(NewIntegrationTestArgs{
|
|
Description: "Create a new branch and worktree from a branch, then switch back to the main worktree via the branches view",
|
|
ExtraCmdArgs: []string{},
|
|
Skip: false,
|
|
SetupConfig: func(config *config.AppConfig) {},
|
|
SetupRepo: func(shell *Shell) {
|
|
shell.NewBranch("mybranch")
|
|
shell.CreateFileAndAdd("README.md", "hello world")
|
|
shell.Commit("initial commit")
|
|
},
|
|
Run: func(t *TestDriver, keys config.KeybindingConfig) {
|
|
t.Views().Branches().
|
|
Focus().
|
|
Lines(
|
|
Contains("mybranch"),
|
|
).
|
|
Press(keys.Universal.NewWorktree).
|
|
Tap(func() {
|
|
t.ExpectPopup().Menu().
|
|
Title(Equals("New worktree")).
|
|
Select(Contains("New branch and worktree from 'mybranch'")).
|
|
Confirm()
|
|
|
|
t.ExpectPopup().Prompt().
|
|
Title(Equals("New branch and worktree name")).
|
|
Type("newbranch").
|
|
Confirm()
|
|
|
|
// no existing worktrees and no configured default path, so the
|
|
// only candidate location is the repo's parent directory; accept it
|
|
t.ExpectPopup().Menu().
|
|
Title(Equals("Worktree location")).
|
|
Confirm()
|
|
}).
|
|
// confirm we're still focused on the branches view
|
|
IsFocused().
|
|
Lines(
|
|
Contains("newbranch").IsSelected(),
|
|
Contains("mybranch (worktree repo)"),
|
|
).
|
|
NavigateToLine(Contains("mybranch")).
|
|
Press(keys.Universal.Select).
|
|
Tap(func() {
|
|
t.ExpectPopup().Confirmation().
|
|
Title(Equals("Switch to worktree")).
|
|
Content(Equals("This branch is checked out by worktree repo. Do you want to switch to that worktree?")).
|
|
Confirm()
|
|
}).
|
|
Lines(
|
|
Contains("mybranch").IsSelected(),
|
|
// the worktree's directory name matches the branch name, so the
|
|
// branches view shows the compact "(worktree)" with no name
|
|
Contains("newbranch (worktree)"),
|
|
).
|
|
// Confirm the files view is still showing in the files window
|
|
Press(keys.Universal.PrevBlock)
|
|
|
|
t.Views().Files().
|
|
IsFocused()
|
|
},
|
|
})
|