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

Function resolveFileIdInTree

src/utils/resolveFileIdInTree.js:11–34  ·  view source on GitHub ↗
({ fs, cache, gitdir, oid, fileId })

Source from the content-addressed store, hash-verified

9const EMPTY_OID = 'e69de29bb2d1d6434b8b29ae775ad8c2e48c5391'
10
11export async function resolveFileIdInTree({ fs, cache, gitdir, oid, fileId }) {
12 if (fileId === EMPTY_OID) return
13 const _oid = oid
14 let filepath
15 const result = await resolveTree({ fs, cache, gitdir, oid })
16 const tree = result.tree
17 if (fileId === result.oid) {
18 filepath = result.path
19 } else {
20 filepath = await _resolveFileId({
21 fs,
22 cache,
23 gitdir,
24 tree,
25 fileId,
26 oid: _oid,
27 })
28 if (Array.isArray(filepath)) {
29 if (filepath.length === 0) filepath = undefined
30 else if (filepath.length === 1) filepath = filepath[0]
31 }
32 }
33 return filepath
34}
35
36async function _resolveFileId({
37 fs,

Callers 1

_logFunction · 0.90

Calls 2

resolveTreeFunction · 0.90
_resolveFileIdFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…