MCPcopy Create free account
hub / github.com/bearlyai/OpenADE / handleListWorkTrees

Function handleListWorkTrees

projects/electron/src/modules/code/git.ts:1316–1343  ·  view source on GitHub ↗

* List all worktrees (supports subdirectories)

(params: ListWorkTreesParams)

Source from the content-addressed store, hash-verified

1314 * List all worktrees (supports subdirectories)
1315 */
1316async function handleListWorkTrees(params: ListWorkTreesParams): Promise<ListWorkTreesResponse> {
1317 const startTime = Date.now()
1318 logger.info("[Git:listWorkTrees] Listing worktrees", JSON.stringify({ repoDir: params.repoDir }))
1319
1320 try {
1321 validateRepoDir(params.repoDir)
1322
1323 // Resolve git info (handles subdirectories)
1324 const { repoRoot } = await resolveGitInfo(params.repoDir)
1325
1326 const listResult = await execGit(["worktree", "list", "--porcelain"], repoRoot)
1327 if (!listResult.success) {
1328 throw new Error(`Failed to list worktrees: ${listResult.stderr}`)
1329 }
1330
1331 const allWorktrees = parseWorktreeList(listResult.stdout)
1332 const baseDir = getWorktreeBaseDir()
1333
1334 // Filter for only our managed worktrees
1335 const worktrees = allWorktrees.filter((wt) => wt.path.startsWith(baseDir))
1336
1337 logger.info("[Git:listWorkTrees] Worktrees listed", JSON.stringify({ count: worktrees.length, duration: Date.now() - startTime }))
1338 return { worktrees }
1339 } catch (error: any) {
1340 logger.error("[Git:listWorkTrees] Error:", JSON.stringify({ error: error.message, stack: error.stack, duration: Date.now() - startTime }))
1341 throw error
1342 }
1343}
1344
1345/**
1346 * Commit changes in a worktree

Callers 1

listRuntimeWorkTreesFunction · 0.85

Calls 6

validateRepoDirFunction · 0.85
resolveGitInfoFunction · 0.85
execGitFunction · 0.85
parseWorktreeListFunction · 0.85
getWorktreeBaseDirFunction · 0.85
errorMethod · 0.80

Tested by

no test coverage detected