1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-07-30 03:23:08 +03:00

Support creating worktrees from refs

This commit is contained in:
Jesse Duffield
2023-07-16 19:39:53 +10:00
parent 4b2622d93b
commit 18ea68c23a
9 changed files with 239 additions and 29 deletions

View File

@ -204,7 +204,7 @@ func (self *BranchesController) press(selectedBranch *models.Branch) error {
if selectedBranch.CheckedOutByOtherWorktree {
worktreeForRef, ok := self.worktreeForBranch(selectedBranch)
if ok && !self.c.Git().Worktree.IsCurrentWorktree(worktreeForRef) {
if ok && !self.c.Git().Worktree.IsCurrentWorktree(worktreeForRef.Path) {
return self.promptToCheckoutWorktree(worktreeForRef)
}
}
@ -228,7 +228,7 @@ func (self *BranchesController) promptToCheckoutWorktree(worktree *models.Worktr
Title: "Switch to worktree",
Prompt: fmt.Sprintf("This branch is checked out by worktree %s. Do you want to switch to that worktree?", worktree.Name()),
HandleConfirm: func() error {
return self.c.Helpers().Worktree.Switch(worktree, context.LOCAL_BRANCHES_CONTEXT_KEY)
return self.c.Helpers().Worktree.Switch(worktree.Path, context.LOCAL_BRANCHES_CONTEXT_KEY)
},
})
}
@ -346,7 +346,7 @@ func (self *BranchesController) promptWorktreeBranchDelete(selectedBranch *model
{
Label: "Switch to worktree",
OnPress: func() error {
return self.c.Helpers().Worktree.Switch(worktree, context.LOCAL_BRANCHES_CONTEXT_KEY)
return self.c.Helpers().Worktree.Switch(worktree.Path, context.LOCAL_BRANCHES_CONTEXT_KEY)
},
},
{