WorktreeForBranch returns the worktree that has branch checked out, or nil when the branch is not associated with any worktree.
(worktrees []Worktree, branch string)
| 88 | // WorktreeForBranch returns the worktree that has branch checked out, or nil |
| 89 | // when the branch is not associated with any worktree. |
| 90 | func WorktreeForBranch(worktrees []Worktree, branch string) *Worktree { |
| 91 | branchRef := "refs/heads/" + branch |
| 92 | for i := range worktrees { |
| 93 | if worktrees[i].Ref == branchRef { |
| 94 | return &worktrees[i] |
| 95 | } |
| 96 | } |
| 97 | return nil |
| 98 | } |
no outgoing calls