MCPcopy Create free account
hub / github.com/isomorphic-git/isomorphic-git / resolveTree

Function resolveTree

src/utils/resolveTree.js:7–27  ·  view source on GitHub ↗
({ fs, cache, gitdir, oid })

Source from the content-addressed store, hash-verified

5import { _readObject } from '../storage/readObject.js'
6
7export async function resolveTree({ fs, cache, gitdir, oid }) {
8 // Empty tree - bypass `readObject`
9 if (oid === '4b825dc642cb6eb9a060e54bf8d69288fbee4904') {
10 return { tree: GitTree.from([]), oid }
11 }
12 const { type, object } = await _readObject({ fs, cache, gitdir, oid })
13 // Resolve annotated tag objects to whatever
14 if (type === 'tag') {
15 oid = GitAnnotatedTag.from(object).parse().object
16 return resolveTree({ fs, cache, gitdir, oid })
17 }
18 // Resolve commits to trees
19 if (type === 'commit') {
20 oid = GitCommit.from(object).parse().tree
21 return resolveTree({ fs, cache, gitdir, oid })
22 }
23 if (type !== 'tree') {
24 throw new ObjectTypeError(oid, type, 'tree')
25 }
26 return { tree: GitTree.from(object), oid }
27}

Callers 4

resolveFileIdInTreeFunction · 0.90
resolveFilepathFunction · 0.90
_readTreeFunction · 0.90
constructorMethod · 0.90

Calls 3

_readObjectFunction · 0.90
fromMethod · 0.45
parseMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…