MCPcopy Create free account
hub / github.com/MiniCodeMonkey/chief / DetectOrphanedWorktrees

Function DetectOrphanedWorktrees

internal/git/worktree.go:201–217  ·  view source on GitHub ↗

DetectOrphanedWorktrees scans .chief/worktrees/ and returns a map of PRD name -> absolute worktree path for worktrees that exist on disk. The caller is responsible for determining which are orphaned (i.e., have no corresponding registered/running PRD).

(baseDir string)

Source from the content-addressed store, hash-verified

199// for worktrees that exist on disk. The caller is responsible for determining which are orphaned
200// (i.e., have no corresponding registered/running PRD).
201func DetectOrphanedWorktrees(baseDir string) map[string]string {
202 worktreesDir := filepath.Join(baseDir, ".chief", "worktrees")
203 entries, err := os.ReadDir(worktreesDir)
204 if err != nil {
205 return nil
206 }
207
208 result := make(map[string]string)
209 for _, entry := range entries {
210 if !entry.IsDir() {
211 continue
212 }
213 absPath := filepath.Join(worktreesDir, entry.Name())
214 result[entry.Name()] = absPath
215 }
216 return result
217}
218
219// MergeBranch merges a branch into the current branch, returning conflicting file list on failure.
220func MergeBranch(repoDir, branch string) ([]string, error) {

Callers 2

RefreshMethod · 0.92

Calls 1

NameMethod · 0.65

Tested by 1