MCPcopy Create free account
hub / github.com/cloudflare/computer / topmostUntrackedDir

Function topmostUntrackedDir

packages/computer/src/git/worktree.ts:308–318  ·  view source on GitHub ↗
(path: string, trackedDirs: Set<string>)

Source from the content-addressed store, hash-verified

306}
307
308function topmostUntrackedDir(path: string, trackedDirs: Set<string>): string {
309 // Walk from the file up to the root; the first dir off the root
310 // that isn't tracked is the top of the untracked subtree.
311 const segments = path.split("/");
312 let prefix = "";
313 for (let i = 0; i < segments.length - 1; i++) {
314 prefix = prefix === "" ? segments[i] : `${prefix}/${segments[i]}`;
315 if (!trackedDirs.has(prefix)) return prefix;
316 }
317 return dirname(path);
318}
319
320function dirname(path: string): string {
321 const i = path.lastIndexOf("/");

Callers 1

cleanWithFunction · 0.85

Calls 2

hasMethod · 0.80
dirnameFunction · 0.70

Tested by

no test coverage detected