MCPcopy Create free account
hub / github.com/UsefulSoftwareCo/executor / walkTree

Function walkTree

packages/plugins/apps/src/git-client/packfile.ts:584–607  ·  view source on GitHub ↗
(parsed: ParsedPack, commitSha: string)

Source from the content-addressed store, hash-verified

582
583// Walk from commit sha to a flat file list. Blobs must be present in pack.
584export function walkTree(parsed: ParsedPack, commitSha: string): TreeFile[] {
585 const commit = parsed.objects.get(commitSha);
586 if (!commit) throw new PackParseError(`commit ${commitSha} not in pack`);
587 const { tree } = parseCommit(commit.data);
588 const files: TreeFile[] = [];
589 const recur = (treeSha: string, prefix: string) => {
590 const t = parsed.objects.get(treeSha);
591 if (!t) throw new PackParseError(`tree ${treeSha} not in pack`);
592 for (const e of parseTree(t.data)) {
593 const full = prefix ? `${prefix}/${e.name}` : e.name;
594 if (e.mode === "40000" || e.mode === "040000") {
595 recur(e.sha, full);
596 } else if (e.mode === "160000") {
597 // gitlink/submodule; skip
598 } else {
599 const blob = parsed.objects.get(e.sha);
600 if (!blob) throw new PackParseError(`blob ${e.sha} (${full}) not in pack`);
601 files.push({ path: full, mode: e.mode, sha: e.sha, bytes: blob.data });
602 }
603 }
604 };
605 recur(tree, "");
606 return files;
607}
608
609export { inflateZlib, inflateRaw };

Callers 2

app-source.test.tsFile · 0.90
handFetchFunction · 0.90

Calls 3

parseCommitFunction · 0.85
recurFunction · 0.85
getMethod · 0.65

Tested by

no test coverage detected