MCPcopy Create free account
hub / github.com/idosal/git-mcp / recurse

Function recurse

src/api/tools/commonTools.ts:1011–1029  ·  view source on GitHub ↗
(prefix: string)

Source from the content-addressed store, hash-verified

1009
1010 // Define an inner async recursion
1011 async function recurse(prefix: string) {
1012 let cursor;
1013 do {
1014 // 1. List one page of prefixes under `prefix`
1015 const listResult = await bucket.list({ prefix, delimiter: "/", cursor });
1016 const { delimitedPrefixes = [], truncated } = listResult;
1017
1018 // 2. For each child prefix, record it and recurse into it
1019 // Ensure the child prefix ends with '/' before adding/recursing
1020 for (const childPrefix of delimitedPrefixes) {
1021 const ensuredChildPrefix = childPrefix.endsWith("/")
1022 ? childPrefix
1023 : childPrefix + "/";
1024 all.push(ensuredChildPrefix);
1025 await recurse(ensuredChildPrefix);
1026 }
1027 cursor = truncated ? listResult.cursor : undefined;
1028 } while (cursor);
1029 }
1030
1031 // Kick off recursion
1032 await recurse(startPrefix);

Callers 1

listAllSubfoldersFunction · 0.85

Calls 1

listMethod · 0.65

Tested by

no test coverage detected