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

Remove IO logic from presentation code for worktrees

We're doing all the IO in our workers loader method so that we don't need to do any
in our presentation code
This commit is contained in:
Jesse Duffield
2023-07-28 16:17:15 +10:00
parent 2b24c15938
commit de57cfd6ff
9 changed files with 57 additions and 86 deletions

View File

@ -203,7 +203,7 @@ func (self *BranchesController) press(selectedBranch *models.Branch) error {
}
worktreeForRef, ok := self.worktreeForBranch(selectedBranch)
if ok && !self.c.Git().Worktree.IsCurrentWorktree(worktreeForRef.Path) {
if ok && !worktreeForRef.Current() {
return self.promptToCheckoutWorktree(worktreeForRef)
}
@ -220,7 +220,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.Path, context.LOCAL_BRANCHES_CONTEXT_KEY)
return self.c.Helpers().Worktree.Switch(worktree, context.LOCAL_BRANCHES_CONTEXT_KEY)
},
})
}
@ -342,7 +342,7 @@ func (self *BranchesController) promptWorktreeBranchDelete(selectedBranch *model
{
Label: "Switch to worktree",
OnPress: func() error {
return self.c.Helpers().Worktree.Switch(worktree.Path, context.LOCAL_BRANCHES_CONTEXT_KEY)
return self.c.Helpers().Worktree.Switch(worktree, context.LOCAL_BRANCHES_CONTEXT_KEY)
},
},
{
@ -432,7 +432,7 @@ func (self *BranchesController) fastForward(branch *models.Branch) error {
worktreeGitDir := ""
// if it is the current worktree path, no need to specify the path
if !git_commands.IsCurrentWorktree(worktree.Path) {
if !worktree.Current() {
worktreeGitDir = worktree.GitDir
}