(parsed: ParsedPack, commitSha: string)
| 582 | |
| 583 | // Walk from commit sha to a flat file list. Blobs must be present in pack. |
| 584 | export 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 | |
| 609 | export { inflateZlib, inflateRaw }; |
no test coverage detected