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

Function resolveFilepath

src/utils/resolveFilepath.js:9–37  ·  view source on GitHub ↗
({ fs, cache, gitdir, oid, filepath })

Source from the content-addressed store, hash-verified

7import { resolveTree } from '../utils/resolveTree.js'
8
9export async function resolveFilepath({ fs, cache, gitdir, oid, filepath }) {
10 // Ensure there are no leading or trailing directory separators.
11 // I was going to do this automatically, but then found that the Git Terminal for Windows
12 // auto-expands --filepath=/src/utils to --filepath=C:/Users/Will/AppData/Local/Programs/Git/src/utils
13 // so I figured it would be wise to promote the behavior in the application layer not just the library layer.
14 if (filepath.startsWith('/')) {
15 throw new InvalidFilepathError('leading-slash')
16 } else if (filepath.endsWith('/')) {
17 throw new InvalidFilepathError('trailing-slash')
18 }
19 const _oid = oid
20 const result = await resolveTree({ fs, cache, gitdir, oid })
21 const tree = result.tree
22 if (filepath === '') {
23 oid = result.oid
24 } else {
25 const pathArray = filepath.split('/')
26 oid = await _resolveFilepath({
27 fs,
28 cache,
29 gitdir,
30 tree,
31 pathArray,
32 oid: _oid,
33 filepath,
34 })
35 }
36 return oid
37}
38
39async function _resolveFilepath({
40 fs,

Callers 5

_readTreeFunction · 0.90
_logFunction · 0.90
_readBlobFunction · 0.90
readObjectFunction · 0.90
resetIndexFunction · 0.90

Calls 2

resolveTreeFunction · 0.90
_resolveFilepathFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…