MCPcopy
hub / github.com/coder/mux / getMainWorktreeFromWorktree

Function getMainWorktreeFromWorktree

src/node/git.ts:222–240  ·  view source on GitHub ↗
(worktreePath: string)

Source from the content-addressed store, hash-verified

220 * @returns Path to the main repository, or null if not found
221 */
222export async function getMainWorktreeFromWorktree(worktreePath: string): Promise<string | null> {
223 try {
224 // Get the worktree list from the worktree itself
225 using proc = execFileAsync("git", ["-C", worktreePath, "worktree", "list", "--porcelain"]);
226 const { stdout } = await proc.result;
227 const lines = stdout.split("\n");
228
229 // The first worktree in the list is always the main worktree
230 for (const line of lines) {
231 if (line.startsWith("worktree ")) {
232 return line.slice("worktree ".length);
233 }
234 }
235
236 return null;
237 } catch {
238 return null;
239 }
240}
241
242export async function removeWorktree(
243 projectPath: string,

Callers

nothing calls this directly

Calls 1

execFileAsyncFunction · 0.90

Tested by

no test coverage detected