Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var AddFromBranch = NewIntegrationTest(NewIntegrationTestArgs{ Description: "Add a worktree via the branches view, 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.Worktrees.ViewWorktreeOptions). Tap(func() { t.ExpectPopup().Menu(). Title(Equals("Worktree")). Select(Contains(`Create worktree from mybranch`).DoesNotContain("detached")). Confirm() t.ExpectPopup().Prompt(). Title(Equals("New worktree path")). Type("../linked-worktree"). Confirm() t.ExpectPopup().Prompt(). Title(Equals("New branch name")). Type("newbranch"). Confirm() }). IsFocused(). Lines( Contains("newbranch").IsSelected(), Contains("mybranch (worktree)"), ). 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(), Contains("newbranch (worktree)"), ). Press(keys.Universal.PrevBlock) t.Views().Files(). IsFocused() }, })
View Source
var AddFromBranchDetached = NewIntegrationTest(NewIntegrationTestArgs{ Description: "Add a detached 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.Worktrees.ViewWorktreeOptions). Tap(func() { t.ExpectPopup().Menu(). Title(Equals("Worktree")). Select(Contains(`Create worktree from mybranch (detached)`)). Confirm() t.ExpectPopup().Prompt(). Title(Equals("New worktree path")). Type("../linked-worktree"). Confirm() }). IsFocused(). Lines( Contains("(no branch)").IsSelected(), Contains("mybranch (worktree)"), ) t.Views().Status(). Content(Contains("repo(linked-worktree)")) }, })
View Source
var AddFromCommit = NewIntegrationTest(NewIntegrationTestArgs{ Description: "Add a worktree via the commits 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") shell.EmptyCommit("commit two") }, Run: func(t *TestDriver, keys config.KeybindingConfig) { t.Views().Commits(). Focus(). Lines( Contains("commit two").IsSelected(), Contains("initial commit"), ). NavigateToLine(Contains("initial commit")). Press(keys.Worktrees.ViewWorktreeOptions). Tap(func() { t.ExpectPopup().Menu(). Title(Equals("Worktree")). Select(MatchesRegexp(`Create worktree from .*`).DoesNotContain("detached")). Confirm() t.ExpectPopup().Prompt(). Title(Equals("New worktree path")). Type("../linked-worktree"). Confirm() t.ExpectPopup().Prompt(). Title(Equals("New branch name")). Type("newbranch"). Confirm() }). Lines( Contains("initial commit"), ) t.Views().Branches(). IsFocused(). Lines( Contains("newbranch").IsSelected(), Contains("mybranch (worktree)"), ) }, })
View Source
var AssociateBranchBisect = NewIntegrationTest(NewIntegrationTestArgs{ Description: "Verify that when you start a bisect in a linked worktree, Lazygit still associates the worktree with the branch", 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") shell.EmptyCommit("commit 2") shell.EmptyCommit("commit 3") shell.AddWorktree("mybranch", "../linked-worktree", "newbranch") }, Run: func(t *TestDriver, keys config.KeybindingConfig) { t.Views().Branches(). Focus(). Lines( Contains("mybranch").IsSelected(), Contains("newbranch (worktree)"), ) t.Views().Commits(). Focus(). SelectedLine(Contains("commit 3")). Press(keys.Commits.ViewBisectOptions). Tap(func() { t.ExpectPopup().Menu(). Title(Equals("Bisect")). Select(MatchesRegexp(`Mark .* as bad`)). Confirm() t.Views().Information().Content(Contains("Bisecting")) }). NavigateToLine(Contains("initial commit")). Press(keys.Commits.ViewBisectOptions). Tap(func() { t.ExpectPopup().Menu(). Title(Equals("Bisect")). Select(MatchesRegexp(`Mark .* as good`)). Confirm() }) t.Views().Branches(). Focus(). NavigateToLine(Contains("newbranch")). Press(keys.Universal.Select). Tap(func() { t.ExpectPopup().Confirmation(). Title(Equals("Switch to worktree")). Content(Equals("This branch is checked out by worktree linked-worktree. Do you want to switch to that worktree?")). Confirm() t.Views().Information().Content(DoesNotContain("Bisecting")) }). Lines( Contains("newbranch").IsSelected(), Contains("mybranch (worktree)"), ) t.Views().Branches(). Focus(). 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() }) }, })
View Source
var AssociateBranchRebase = NewIntegrationTest(NewIntegrationTestArgs{ Description: "Verify that when you start a rebase in a linked or main worktree, Lazygit still associates the worktree with the branch", 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") shell.EmptyCommit("commit 2") shell.EmptyCommit("commit 3") shell.AddWorktree("mybranch", "../linked-worktree", "newbranch") }, Run: func(t *TestDriver, keys config.KeybindingConfig) { t.Views().Branches(). Focus(). Lines( Contains("mybranch").IsSelected(), Contains("newbranch (worktree)"), ) t.Views().Commits(). Focus(). NavigateToLine(Contains("commit 2")). Press(keys.Universal.Edit) t.Views().Information().Content(Contains("Rebasing")) t.Views().Branches(). Focus(). NavigateToLine(Contains("newbranch")). Press(keys.Universal.Select). Tap(func() { t.ExpectPopup().Confirmation(). Title(Equals("Switch to worktree")). Content(Equals("This branch is checked out by worktree linked-worktree. Do you want to switch to that worktree?")). Confirm() t.Views().Information().Content(DoesNotContain("Rebasing")) }). Lines( Contains("newbranch").IsSelected(), Contains("mybranch (worktree)"), ) t.Views().Commits(). Focus(). NavigateToLine(Contains("commit 2")). Press(keys.Universal.Edit) t.Views().Information().Content(Contains("Rebasing")) t.Views().Branches(). Focus(). 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("(no branch").IsSelected(), Contains("mybranch"), Contains("newbranch (worktree)"), ) }, })
View Source
var BareRepo = NewIntegrationTest(NewIntegrationTestArgs{ Description: "Open lazygit in the worktree of a bare repo and do a rebase/bisect", ExtraCmdArgs: []string{}, Skip: false, SetupConfig: func(config *config.AppConfig) {}, SetupRepo: func(shell *Shell) { shell.NewBranch("mybranch") shell.CreateFileAndAdd("blah", "blah") shell.Commit("initial commit") shell.EmptyCommit("commit two") shell.EmptyCommit("commit three") shell.RunCommand([]string{"git", "clone", "--bare", ".", "../.bare"}) shell.DeleteFile(".git") shell.Chdir("..") shell.DeleteFile("repo") shell.RunCommand([]string{"git", "--git-dir", ".bare", "worktree", "add", "-b", "repo", "repo", "mybranch"}) shell.RunCommand([]string{"git", "--git-dir", ".bare", "worktree", "add", "-b", "worktree2", "worktree2", "mybranch"}) }, Run: func(t *TestDriver, keys config.KeybindingConfig) { t.Views().Branches(). Lines( Contains("repo"), Contains("mybranch"), Contains("worktree2 (worktree)"), ) t.Views().Commits(). Focus(). Lines( Contains("commit three").IsSelected(), Contains("commit two"), Contains("initial commit"), ). Press(keys.Commits.MoveDownCommit). Lines( Contains("commit two"), Contains("commit three").IsSelected(), Contains("initial commit"), ). NavigateToLine(Contains("commit two")). Press(keys.Commits.ViewBisectOptions). Tap(func() { t.ExpectPopup().Menu(). Title(Equals("Bisect")). Select(MatchesRegexp(`Mark .* as bad`)). Confirm() t.Views().Information().Content(Contains("Bisecting")) }). NavigateToLine(Contains("initial commit")). Press(keys.Commits.ViewBisectOptions). Tap(func() { t.ExpectPopup().Menu(). Title(Equals("Bisect")). Select(MatchesRegexp(`Mark .* as good`)). Confirm() t.Views().Information().Content(Contains("Bisecting")) }) t.Views().Worktrees(). Focus(). Lines( Contains("repo").IsSelected(), Contains("worktree2"), ). NavigateToLine(Contains("worktree2")). Press(keys.Universal.Select). Lines( Contains("worktree2").IsSelected(), Contains("repo"), ) }, })
View Source
var Crud = NewIntegrationTest(NewIntegrationTestArgs{ Description: "From the worktrees view, add a work tree, switch to it, switch back, and remove it", 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(). Lines( Contains("mybranch"), ) t.Views().Status(). Lines( Contains("repo → mybranch"), ) t.Views().Worktrees(). Focus(). Lines( Contains("repo (main)"), ). Press(keys.Universal.New). Tap(func() { t.ExpectPopup().Menu(). Title(Equals("Worktree")). Select(Contains(`Create worktree from ref`).DoesNotContain(("detached"))). Confirm() t.ExpectPopup().Prompt(). Title(Equals("New worktree base ref")). InitialText(Equals("mybranch")). Confirm() t.ExpectPopup().Prompt(). Title(Equals("New worktree path")). Type("../linked-worktree"). Confirm() t.ExpectPopup().Prompt(). Title(Equals("New branch name (leave blank to checkout mybranch)")). Type("newbranch"). Confirm() }). Lines( Contains("linked-worktree").IsSelected(), Contains("repo (main)"), ). IsFocused() t.Views().Status(). Lines( Contains("repo(linked-worktree) → newbranch"), ) t.Views().Branches(). Lines( Contains("newbranch"), Contains("mybranch"), ) t.Views().Worktrees(). Press(keys.Universal.Remove). Tap(func() { t.ExpectPopup().Alert(). Title(Equals("Error")). Content(Equals("You cannot remove the current worktree!")). Confirm() }). NavigateToLine(Contains("repo (main)")). Press(keys.Universal.Remove). Tap(func() { t.ExpectPopup().Alert(). Title(Equals("Error")). Content(Equals("You cannot remove the main worktree!")). Confirm() }). Press(keys.Universal.Select). Lines( Contains("repo (main)").IsSelected(), Contains("linked-worktree"), ) t.Views().Branches(). Lines( Contains("mybranch"), Contains("newbranch"), ) t.Views().Worktrees(). NavigateToLine(Contains("linked-worktree")). Press(keys.Universal.Remove). Tap(func() { t.ExpectPopup().Confirmation(). Title(Equals("Remove worktree")). Content(Contains("Are you sure you want to remove worktree 'linked-worktree'?")). Confirm() }). Lines( Contains("repo (main)").IsSelected(), ) }, })
View Source
var CustomCommand = NewIntegrationTest(NewIntegrationTestArgs{ Description: "Verify that custom commands work with worktrees by deleting a worktree via a custom command", ExtraCmdArgs: []string{}, Skip: false, SetupConfig: func(cfg *config.AppConfig) { cfg.UserConfig.CustomCommands = []config.CustomCommand{ { Key: "d", Context: "worktrees", Command: "git worktree remove {{ .SelectedWorktree.Path | quote }}", }, } }, SetupRepo: func(shell *Shell) { shell.NewBranch("mybranch") shell.CreateFileAndAdd("README.md", "hello world") shell.Commit("initial commit") shell.AddWorktree("mybranch", "../linked-worktree", "newbranch") }, Run: func(t *TestDriver, keys config.KeybindingConfig) { t.Views().Worktrees(). Focus(). Lines( Contains("repo (main)"), Contains("linked-worktree"), ). NavigateToLine(Contains("linked-worktree")). Press("d"). Lines( Contains("repo (main)"), ) }, })
View Source
var DetachWorktreeFromBranch = NewIntegrationTest(NewIntegrationTestArgs{ Description: "Detach a worktree from 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") shell.EmptyCommit("commit 2") shell.EmptyCommit("commit 3") shell.AddWorktree("mybranch", "../linked-worktree", "newbranch") }, Run: func(t *TestDriver, keys config.KeybindingConfig) { t.Views().Branches(). Focus(). Lines( Contains("mybranch").IsSelected(), Contains("newbranch (worktree)"), ). NavigateToLine(Contains("newbranch")). Press(keys.Universal.Remove). Tap(func() { t.ExpectPopup().Menu(). Title(Equals("Branch newbranch is checked out by worktree linked-worktree")). Select(Equals("Detach worktree")). Confirm() }). Lines( Contains("mybranch"), Contains("newbranch").DoesNotContain("(worktree)").IsSelected(), ) t.Views().Worktrees(). Focus(). Lines( Contains("repo (main)").IsSelected(), Contains("linked-worktree"), ) }, })
View Source
var FastForwardWorktreeBranch = NewIntegrationTest(NewIntegrationTestArgs{ Description: "Fast-forward a linked worktree branch from another worktree", 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") shell.EmptyCommit("two") shell.EmptyCommit("three") shell.NewBranch("newbranch") shell.CloneIntoRemote("origin") shell.SetBranchUpstream("mybranch", "origin/mybranch") shell.SetBranchUpstream("newbranch", "origin/newbranch") shell.HardReset("HEAD^") shell.Checkout("mybranch") shell.HardReset("HEAD^") shell.AddWorktreeCheckout("newbranch", "../linked-worktree") }, Run: func(t *TestDriver, keys config.KeybindingConfig) { t.Views().Branches(). Focus(). Lines( Contains("mybranch").Contains("↓1").IsSelected(), Contains("newbranch (worktree)").Contains("↓1"), ). Press(keys.Branches.FastForward). Lines( Contains("mybranch").Contains("✓").IsSelected(), Contains("newbranch (worktree)").Contains("↓1"), ). NavigateToLine(Contains("newbranch (worktree)")). Press(keys.Branches.FastForward). Lines( Contains("mybranch").Contains("✓"), Contains("newbranch (worktree)").Contains("✓").IsSelected(), ) }, })
View Source
var ForceRemoveWorktree = NewIntegrationTest(NewIntegrationTestArgs{ Description: "Force remove a dirty worktree", 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") shell.EmptyCommit("commit 2") shell.EmptyCommit("commit 3") shell.AddWorktree("mybranch", "../linked-worktree", "newbranch") shell.AddFileInWorktree("../linked-worktree") }, Run: func(t *TestDriver, keys config.KeybindingConfig) { t.Views().Worktrees(). Focus(). Lines( Contains("repo (main)").IsSelected(), Contains("linked-worktree"), ). NavigateToLine(Contains("linked-worktree")). Press(keys.Universal.Remove). Tap(func() { t.ExpectPopup().Confirmation(). Title(Equals("Remove worktree")). Content(Equals("Are you sure you want to remove worktree 'linked-worktree'?")). Confirm() t.ExpectPopup().Confirmation(). Title(Equals("Remove worktree")). Content(Equals("'linked-worktree' contains modified or untracked files (to be honest, it could contain both). Are you sure you want to remove it?")). Confirm() }). Lines( Contains("repo (main)").IsSelected(), ) }, })
View Source
var RemoveWorktreeFromBranch = NewIntegrationTest(NewIntegrationTestArgs{ Description: "Remove a worktree from 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") shell.EmptyCommit("commit 2") shell.EmptyCommit("commit 3") shell.AddWorktree("mybranch", "../linked-worktree", "newbranch") shell.AddFileInWorktree("../linked-worktree") }, Run: func(t *TestDriver, keys config.KeybindingConfig) { t.Views().Branches(). Focus(). Lines( Contains("mybranch").IsSelected(), Contains("newbranch (worktree)"), ). NavigateToLine(Contains("newbranch")). Press(keys.Universal.Remove). Tap(func() { t.ExpectPopup().Menu(). Title(Equals("Branch newbranch is checked out by worktree linked-worktree")). Select(Equals("Remove worktree")). Confirm() t.ExpectPopup().Confirmation(). Title(Equals("Remove worktree")). Content(Equals("Are you sure you want to remove worktree 'linked-worktree'?")). Confirm() t.ExpectPopup().Confirmation(). Title(Equals("Remove worktree")). Content(Equals("'linked-worktree' contains modified or untracked files (to be honest, it could contain both). Are you sure you want to remove it?")). Confirm() }). Lines( Contains("mybranch"), Contains("newbranch").DoesNotContain("(worktree)").IsSelected(), ) t.Views().Worktrees(). Focus(). Lines( Contains("repo (main)").IsSelected(), ) }, })
View Source
var ResetWindowTabs = NewIntegrationTest(NewIntegrationTestArgs{ Description: "Verify that window tabs are reset whenever switching repos", 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") shell.EmptyCommit("commit 2") shell.EmptyCommit("commit 3") shell.AddWorktree("mybranch", "../linked-worktree", "newbranch") shell.AddFileInWorktree("../linked-worktree") }, Run: func(t *TestDriver, keys config.KeybindingConfig) { t.Views().Remotes(). Focus() t.Views().Worktrees(). Focus(). Lines( Contains("repo (main)").IsSelected(), Contains("linked-worktree"), ). NavigateToLine(Contains("linked-worktree")). Press(keys.Universal.Select). Lines( Contains("linked-worktree").IsSelected(), Contains("repo (main)"), ). Press(keys.Universal.NextBlock) t.Views().Branches(). IsFocused() }, })
View Source
var WorktreeInRepo = NewIntegrationTest(NewIntegrationTestArgs{ Description: "Add a worktree inside the repo, then remove the directory and confirm the worktree is removed", 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(). Lines( Contains("mybranch"), ) t.Views().Worktrees(). Focus(). Lines( Contains("repo (main)"), ). Press(keys.Universal.New). Tap(func() { t.ExpectPopup().Menu(). Title(Equals("Worktree")). Select(Contains(`Create worktree from ref`).DoesNotContain(("detached"))). Confirm() t.ExpectPopup().Prompt(). Title(Equals("New worktree base ref")). InitialText(Equals("mybranch")). Confirm() t.ExpectPopup().Prompt(). Title(Equals("New worktree path")). Type("linked-worktree"). Confirm() t.ExpectPopup().Prompt(). Title(Equals("New branch name (leave blank to checkout mybranch)")). Type("newbranch"). Confirm() }). Lines( Contains("linked-worktree").IsSelected(), Contains("repo (main)"), ). NavigateToLine(Contains("repo (main)")). Press(keys.Universal.Select). Lines( Contains("repo (main)").IsSelected(), Contains("linked-worktree"), ) t.Views().Files(). Focus(). Lines( Contains("linked-worktree"), ). Press(keys.Universal.Remove). Tap(func() { t.ExpectPopup().Menu(). Title(Equals("linked-worktree")). Select(Contains("Discard all changes")). Confirm() }). IsEmpty() t.Views().Worktrees(). Focus(). Lines( Contains("repo (main)").IsSelected(), Contains("linked-worktree (missing)"), ) }, })
Functions ¶
This section is empty.
Types ¶
This section is empty.
Source Files
¶
- add_from_branch.go
- add_from_branch_detached.go
- add_from_commit.go
- associate_branch_bisect.go
- associate_branch_rebase.go
- bare_repo.go
- crud.go
- custom_command.go
- detach_worktree_from_branch.go
- fast_forward_worktree_branch.go
- force_remove_worktree.go
- remove_worktree_from_branch.go
- reset_window_tabs.go
- worktree_in_repo.go
Click to show internal directories.
Click to hide internal directories.