git-fs-s3 0.9.0 → 0.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +34 -2
- package/dist/chunk-G636FB7W.js +143 -0
- package/dist/chunk-G636FB7W.js.map +1 -0
- package/dist/{chunk-PASVUPKR.js → chunk-HO6OPXUS.js} +139 -1
- package/dist/chunk-HO6OPXUS.js.map +1 -0
- package/dist/{chunk-HBOJR5D3.js → chunk-QH3HS7VI.js} +41 -17
- package/dist/chunk-QH3HS7VI.js.map +1 -0
- package/dist/http.js +33 -70
- package/dist/http.js.map +1 -1
- package/dist/index.js +21 -2
- package/dist/index.js.map +1 -1
- package/dist/ops.js +176 -10
- package/dist/ops.js.map +1 -1
- package/dist/s3.js +17 -0
- package/dist/s3.js.map +1 -1
- package/dist/types/edge-utils.d.ts +14 -0
- package/dist/types/http/pack-reuse.d.ts +0 -8
- package/dist/types/http/pkt-line.d.ts +11 -2
- package/dist/types/http/reachability.d.ts +14 -0
- package/dist/types/http/receive-pack.d.ts +13 -6
- package/dist/types/index.d.ts +1 -0
- package/dist/types/object-size.d.ts +6 -0
- package/dist/types/ops/diff.d.ts +15 -2
- package/dist/types/ops/index.d.ts +2 -1
- package/dist/types/ops/submodules.d.ts +13 -0
- package/dist/types/ops/tree.d.ts +1 -1
- package/dist/types/pack-entry.d.ts +63 -0
- package/dist/types/pack-index.d.ts +24 -0
- package/dist/types/semaphore.d.ts +22 -0
- package/dist/types/stores/memory.d.ts +1 -0
- package/dist/types/stores/s3.d.ts +1 -0
- package/dist/types/types.d.ts +10 -0
- package/package.json +1 -1
- package/dist/chunk-HBOJR5D3.js.map +0 -1
- package/dist/chunk-PASVUPKR.js.map +0 -1
- package/dist/chunk-ZB6GNJ2J.js +0 -59
- package/dist/chunk-ZB6GNJ2J.js.map +0 -1
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/cache.ts","../src/errors.ts","../src/git-fs.ts","../src/path.ts","../src/retry.ts","../src/stores/memory.ts"],"sourcesContent":["import { LRUCache } from \"lru-cache\";\nimport type {\n\tListOptions,\n\tListResult,\n\tObjectStat,\n\tObjectStore,\n} from \"./types.js\";\n\nexport interface CacheOptions {\n\t/** Maximum bytes of object data held in memory. Default 50 MiB. */\n\tmaxBytes?: number;\n\t/**\n\t * Largest single entry admitted to the cache. Defaults to a tenth of\n\t * `maxBytes` so one huge packfile cannot evict the whole working set.\n\t */\n\tmaxEntryBytes?: number;\n\t/** Entry time-to-live in milliseconds. Default 60 000. */\n\tttlMs?: number;\n\t/**\n\t * Override the TTL for a specific key (get/head) or list prefix (list),\n\t * in milliseconds. Return `undefined` to fall back to `ttlMs`. Git refs\n\t * (`refs/heads/<branch>`, `HEAD`) are mutable — the same key's value\n\t * changes on every push — unlike content-addressed object keys, which\n\t * never change for a given key and are safe to cache for the full\n\t * `ttlMs`. Without this, a long `ttlMs` tuned for objects also caches\n\t * ref reads that long, so a warm process can keep serving a\n\t * pre-push ref value for the rest of that TTL even though nothing\n\t * changed *this* process's own cache (see `invalidate`) — it just never\n\t * knew to. Give ref-like keys a short override (a few seconds) instead:\n\t * a ref read is one small object, so re-reading it far more often than\n\t * `ttlMs` is cheap, and every read downstream of a fresh ref (tree,\n\t * commit, blob — all keyed by the sha it resolves to) still gets the\n\t * full-length cache/coalescing benefit.\n\t */\n\tttlForKey?: (key: string) => number | undefined;\n\t/**\n\t * Also cache \"key does not exist\" results. Loose-object probes on packed\n\t * repositories are almost always misses, so this saves many round trips —\n\t * but only enable it when a single process is the only writer, otherwise\n\t * another instance's push can be masked for up to `ttlMs`.\n\t */\n\tcacheMisses?: boolean;\n\t/**\n\t * Also cache `list()` results (directory listings and `limit: 1`\n\t * existence probes). Writes through this store keep cached listings\n\t * consistent; after writing to the backend by any other means, call\n\t * `invalidate()` with the affected prefix. Default false.\n\t */\n\tcacheLists?: boolean;\n\t/**\n\t * Collapse concurrent `get`/`head`/`list` calls for the same key into a\n\t * single backend request. Default true.\n\t */\n\tcoalesce?: boolean;\n\t/**\n\t * Return defensive copies from `get` (and copy on admit), so a caller\n\t * mutating returned bytes can't corrupt the cache. Default true. Set\n\t * false when no reader mutates results (isomorphic-git doesn't): every\n\t * hit otherwise copies the whole entry, which for packfiles is megabytes\n\t * per read.\n\t */\n\tcopy?: boolean;\n\t/** Called when a read is answered from cache. */\n\tonHit?: (key: string) => void;\n\t/** Called when a read has to go to the backing store. */\n\tonMiss?: (key: string) => void;\n}\n\n/** An {@link ObjectStore} wrapper that also supports explicit invalidation. */\nexport interface CachedObjectStore extends ObjectStore {\n\t/**\n\t * Drop every cached entry — contents, misses, and listings — whose key\n\t * falls under `prefix` (exact keys included). Call this after the backing\n\t * store was modified by something other than this wrapper.\n\t */\n\tinvalidate(prefix: string): void;\n}\n\nconst MISS = Symbol(\"miss\");\ntype CacheEntry = Uint8Array | typeof MISS;\n\ninterface ListEntry {\n\tresult: ListResult;\n\t/** The raw list prefix this entry describes. */\n\tprefix: string;\n\t/** True for `limit: 1` existence probes. */\n\tprobe: boolean;\n\t/** True when the listing came back with no objects or prefixes. */\n\tempty: boolean;\n}\n\nfunction listEntrySize(entry: ListEntry): number {\n\tlet size = entry.prefix.length + 16;\n\tfor (const o of entry.result.objects) size += o.key.length + 8;\n\tfor (const p of entry.result.prefixes) size += p.length;\n\treturn size;\n}\n\nfunction copyListResult(result: ListResult): ListResult {\n\treturn {\n\t\tobjects: result.objects.map((o) => ({ ...o })),\n\t\tprefixes: [...result.prefixes],\n\t};\n}\n\n/**\n * Wrap an {@link ObjectStore} with an in-process LRU read cache.\n *\n * Git object keys are content-addressed and therefore immutable, which makes\n * them ideal cache entries; mutable keys (refs, packed-refs) are bounded by\n * `ttlMs`. Writes and deletes through this wrapper invalidate their key and\n * any cached listings they affect — with one asymmetry: a non-empty `limit: 1`\n * probe (a \"directory exists\" answer) survives writes underneath it, because\n * adding a key below a prefix cannot make that prefix stop existing, while\n * empty probes and full listings are always dropped.\n */\nexport function createCachedStore(\n\tstore: ObjectStore,\n\toptions: CacheOptions = {},\n): CachedObjectStore {\n\tconst maxBytes = options.maxBytes ?? 50 * 1024 * 1024;\n\tconst maxEntryBytes = options.maxEntryBytes ?? Math.ceil(maxBytes / 10);\n\tconst ttl = options.ttlMs ?? 60_000;\n\tconst ttlForKey = options.ttlForKey;\n\tconst cacheMisses = options.cacheMisses ?? false;\n\tconst cacheLists = options.cacheLists ?? false;\n\tconst coalesce = options.coalesce ?? true;\n\tconst copy = options.copy ?? true;\n\tconst clone = (data: Uint8Array) => (copy ? data.slice() : data);\n\tconst onHit = options.onHit;\n\tconst onMiss = options.onMiss;\n\n\tconst cache = new LRUCache<string, CacheEntry>({\n\t\tmaxSize: maxBytes,\n\t\tsizeCalculation: (value) => (value === MISS ? 1 : value.byteLength || 1),\n\t\tttl,\n\t});\n\tconst listCache = new LRUCache<string, ListEntry>({\n\t\tmaxSize: Math.max(1, Math.ceil(maxBytes / 10)),\n\t\tsizeCalculation: listEntrySize,\n\t\tttl,\n\t});\n\n\tconst pendingGets = new Map<string, Promise<Uint8Array | null>>();\n\tconst pendingHeads = new Map<string, Promise<ObjectStat | null>>();\n\tconst pendingLists = new Map<string, Promise<ListResult>>();\n\n\t/**\n\t * Bumped by every write, delete and invalidation. A backend read that\n\t * started before one of those may finish after it carrying the old answer\n\t * (the old bytes, or \"missing\" for a key that now exists); it still\n\t * answers its own callers, but only a read that saw no write in between\n\t * may populate the cache — otherwise a stale miss could hide a freshly\n\t * written object for the whole TTL.\n\t */\n\tlet generation = 0;\n\tconst unchangedSince = (start: number) => generation === start;\n\n\tconst admit = (key: string, data: Uint8Array) => {\n\t\tif (data.byteLength <= maxEntryBytes) {\n\t\t\tcache.set(key, clone(data), { ttl: ttlForKey?.(key) });\n\t\t}\n\t};\n\n\t/** Drop list entries a write/delete at `key` may have made stale. */\n\tfunction clearStaleListEntries(key: string): void {\n\t\tfor (const [listKey, entry] of listCache.entries()) {\n\t\t\tif (!key.startsWith(entry.prefix)) continue;\n\t\t\tif (entry.probe && !entry.empty) continue;\n\t\t\tlistCache.delete(listKey);\n\t\t}\n\t\t// Readers arriving after this write must not join a listing that\n\t\t// started before it.\n\t\tfor (const listKey of pendingLists.keys()) {\n\t\t\tconst prefix = listKey.split(\"|\").slice(2).join(\"|\");\n\t\t\tif (key.startsWith(prefix)) pendingLists.delete(listKey);\n\t\t}\n\t}\n\n\t/** A write to `key` happened: no in-flight read of it may be joined or cached. */\n\tfunction noteWrite(key: string): void {\n\t\tgeneration++;\n\t\tpendingGets.delete(key);\n\t\tpendingHeads.delete(key);\n\t}\n\n\tfunction coalesced<T>(\n\t\tpending: Map<string, Promise<T>>,\n\t\tkey: string,\n\t\tfn: () => Promise<T>,\n\t): Promise<T> {\n\t\tif (!coalesce) return fn();\n\t\tconst inflight = pending.get(key);\n\t\tif (inflight !== undefined) return inflight;\n\t\tconst p = fn().finally(() => {\n\t\t\tif (pending.get(key) === p) pending.delete(key);\n\t\t});\n\t\tpending.set(key, p);\n\t\treturn p;\n\t}\n\n\treturn {\n\t\tasync get(key: string): Promise<Uint8Array | null> {\n\t\t\tconst cached = cache.get(key);\n\t\t\tif (cached !== undefined) {\n\t\t\t\tonHit?.(key);\n\t\t\t\treturn cached === MISS ? null : clone(cached);\n\t\t\t}\n\t\t\tconst data = await coalesced(pendingGets, key, async () => {\n\t\t\t\tonMiss?.(key);\n\t\t\t\tconst start = generation;\n\t\t\t\tconst fetched = await store.get(key);\n\t\t\t\tif (unchangedSince(start)) {\n\t\t\t\t\tif (fetched !== null) {\n\t\t\t\t\t\tadmit(key, fetched);\n\t\t\t\t\t} else if (cacheMisses) {\n\t\t\t\t\t\tcache.set(key, MISS, { ttl: ttlForKey?.(key) });\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn fetched;\n\t\t\t});\n\t\t\treturn data === null ? null : clone(data);\n\t\t},\n\n\t\tasync put(key: string, data: Uint8Array): Promise<void> {\n\t\t\tnoteWrite(key);\n\t\t\ttry {\n\t\t\t\tawait store.put(key, data);\n\t\t\t} finally {\n\t\t\t\t// Even a failed put may have landed; never keep serving the\n\t\t\t\t// pre-write answer for this key.\n\t\t\t\tnoteWrite(key);\n\t\t\t\tcache.delete(key);\n\t\t\t\tclearStaleListEntries(key);\n\t\t\t}\n\t\t\tadmit(key, data);\n\t\t},\n\n\t\tasync delete(key: string): Promise<void> {\n\t\t\tnoteWrite(key);\n\t\t\ttry {\n\t\t\t\tawait store.delete(key);\n\t\t\t} finally {\n\t\t\t\tnoteWrite(key);\n\t\t\t\tcache.delete(key);\n\t\t\t\tclearStaleListEntries(key);\n\t\t\t}\n\t\t\tif (cacheMisses) {\n\t\t\t\tcache.set(key, MISS, { ttl: ttlForKey?.(key) });\n\t\t\t} else {\n\t\t\t\tcache.delete(key);\n\t\t\t}\n\t\t},\n\n\t\tasync head(key: string): Promise<ObjectStat | null> {\n\t\t\tconst cached = cache.get(key);\n\t\t\tif (cached !== undefined) {\n\t\t\t\tonHit?.(key);\n\t\t\t\treturn cached === MISS ? null : { size: cached.byteLength };\n\t\t\t}\n\t\t\treturn coalesced(pendingHeads, key, async () => {\n\t\t\t\tonMiss?.(key);\n\t\t\t\tconst start = generation;\n\t\t\t\tconst stat = await store.head(key);\n\t\t\t\tif (stat === null && cacheMisses && unchangedSince(start)) {\n\t\t\t\t\tcache.set(key, MISS, { ttl: ttlForKey?.(key) });\n\t\t\t\t}\n\t\t\t\treturn stat;\n\t\t\t});\n\t\t},\n\n\t\tasync list(prefix: string, listOptions?: ListOptions): Promise<ListResult> {\n\t\t\tif (!cacheLists) return store.list(prefix, listOptions);\n\t\t\tconst listKey = `${listOptions?.delimiter ?? \"\"}|${listOptions?.limit ?? \"\"}|${prefix}`;\n\t\t\tconst cached = listCache.get(listKey);\n\t\t\tif (cached !== undefined) {\n\t\t\t\tonHit?.(prefix);\n\t\t\t\treturn copyListResult(cached.result);\n\t\t\t}\n\t\t\tconst result = await coalesced(pendingLists, listKey, async () => {\n\t\t\t\tonMiss?.(prefix);\n\t\t\t\tconst start = generation;\n\t\t\t\tconst fetched = await store.list(prefix, listOptions);\n\t\t\t\tif (!unchangedSince(start)) return fetched;\n\t\t\t\tlistCache.set(\n\t\t\t\t\tlistKey,\n\t\t\t\t\t{\n\t\t\t\t\t\tresult: copyListResult(fetched),\n\t\t\t\t\t\tprefix,\n\t\t\t\t\t\tprobe: listOptions?.limit === 1,\n\t\t\t\t\t\tempty:\n\t\t\t\t\t\t\tfetched.objects.length === 0 && fetched.prefixes.length === 0,\n\t\t\t\t\t},\n\t\t\t\t\t{ ttl: ttlForKey?.(prefix) },\n\t\t\t\t);\n\t\t\t\treturn fetched;\n\t\t\t});\n\t\t\treturn copyListResult(result);\n\t\t},\n\n\t\tinvalidate(prefix: string): void {\n\t\t\tgeneration++;\n\t\t\tfor (const key of [...pendingGets.keys()]) {\n\t\t\t\tif (key.startsWith(prefix)) pendingGets.delete(key);\n\t\t\t}\n\t\t\tfor (const key of [...pendingHeads.keys()]) {\n\t\t\t\tif (key.startsWith(prefix)) pendingHeads.delete(key);\n\t\t\t}\n\t\t\tpendingLists.clear();\n\t\t\tfor (const key of cache.keys()) {\n\t\t\t\tif (key.startsWith(prefix)) cache.delete(key);\n\t\t\t}\n\t\t\tfor (const [listKey, entry] of listCache.entries()) {\n\t\t\t\tif (\n\t\t\t\t\tentry.prefix.startsWith(prefix) ||\n\t\t\t\t\tprefix.startsWith(entry.prefix)\n\t\t\t\t) {\n\t\t\t\t\tlistCache.delete(listKey);\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t};\n}\n","/**\n * Node-style filesystem error carrying a `code` property, which is what\n * isomorphic-git inspects to distinguish \"file not found\" from real failures.\n */\nexport class FsError extends Error {\n\treadonly code: string;\n\treadonly syscall: string;\n\treadonly path: string;\n\n\tconstructor(code: string, syscall: string, path: string) {\n\t\tsuper(`${code}: ${syscall} '${path}'`);\n\t\tthis.name = \"FsError\";\n\t\tthis.code = code;\n\t\tthis.syscall = syscall;\n\t\tthis.path = path;\n\t}\n}\n\nexport const enoent = (syscall: string, path: string) =>\n\tnew FsError(\"ENOENT\", syscall, path);\n\nexport const enotdir = (syscall: string, path: string) =>\n\tnew FsError(\"ENOTDIR\", syscall, path);\n\nexport const enotempty = (syscall: string, path: string) =>\n\tnew FsError(\"ENOTEMPTY\", syscall, path);\n\nexport const einval = (syscall: string, path: string) =>\n\tnew FsError(\"EINVAL\", syscall, path);\n\nexport const eperm = (syscall: string, path: string) =>\n\tnew FsError(\"EPERM\", syscall, path);\n","import { LRUCache } from \"lru-cache\";\nimport { enoent, enotdir, enotempty, eperm } from \"./errors.js\";\nimport { parseLooseObjectPath } from \"./git-layout.js\";\nimport { parsePackDirectory, READABLE_PACK_FILE_KINDS } from \"./pack-files.js\";\nimport { normalizePath, toKey as toKeyWithPrefix } from \"./path.js\";\nimport type {\n\tEncoding,\n\tGitdirFacts,\n\tGitFsClient,\n\tGitFsOptions,\n\tObjectStore,\n\tReadFileOptions,\n\tStat,\n\tWriteFileOptions,\n} from \"./types.js\";\n\nconst FILE_MODE = 0o100644;\nconst DIR_MODE = 0o40000;\n\nconst textEncoder = new TextEncoder();\nconst textDecoder = new TextDecoder();\n\nfunction makeStat(type: \"file\" | \"dir\", size: number): Stat {\n\tconst epoch = new Date(0);\n\treturn {\n\t\ttype,\n\t\tmode: type === \"file\" ? FILE_MODE : DIR_MODE,\n\t\tsize,\n\t\tino: 0,\n\t\tmtimeMs: 0,\n\t\tctimeMs: 0,\n\t\tuid: 0,\n\t\tgid: 0,\n\t\tdev: 0,\n\t\tmtime: epoch,\n\t\tctime: epoch,\n\t\tisFile: () => type === \"file\",\n\t\tisDirectory: () => type === \"dir\",\n\t\tisSymbolicLink: () => false,\n\t};\n}\n\nfunction resolveEncoding(\n\toptions?: ReadFileOptions | WriteFileOptions | Encoding,\n): Encoding | undefined {\n\tif (typeof options === \"string\") return options;\n\treturn options?.encoding;\n}\n\n/**\n * The filesystem returned by {@link createGitFs}: the isomorphic-git client\n * plus git-aware maintenance hooks.\n */\nexport interface GitFs extends GitFsClient {\n\t/**\n\t * Return every file below a directory in one object-store listing. Unlike\n\t * `readdir`, this deliberately does not use a delimiter: object storage can\n\t * enumerate a ref namespace recursively without the stat-per-entry walk a\n\t * POSIX filesystem needs to distinguish files from implicit directories.\n\t * Paths are relative to `dirpath` and never include directory entries.\n\t */\n\tlistFilesRecursively(dirpath: string): Promise<string[]>;\n\t/**\n\t * Probe, with one bounded list, whether `gitdir` contains any loose\n\t * objects, and remember the answer. This is the only way a loose-object\n\t * hint is ever created; call it before full-history walks (commit logs,\n\t * reachability traversals) so fully packed repositories skip every\n\t * guaranteed-miss loose-object read. A later loose write flips the hint\n\t * back, so it cannot go stale mid-push.\n\t */\n\tdetectLooseObjects(gitdir: string): Promise<void>;\n\t/**\n\t * Warm the cache with every pack file under `gitdir` in parallel (plus\n\t * the loose-object hint) before a sequential history walk. Skipped when\n\t * the pack directory holds more than `maxPacks * 2` entries — warming\n\t * only helps when the cache budget actually fits the packs.\n\t */\n\tprefetchPacks(gitdir: string, options?: { maxPacks?: number }): Promise<void>;\n\t/**\n\t * Clear fs-level state (loose-object hints) under `pathPrefix`, and\n\t * forward to the store's `invalidate` when it has one. Call after the\n\t * backing store was modified by something other than this fs.\n\t */\n\tinvalidate(pathPrefix: string): void;\n\t/**\n\t * Declare that `gitdir` exists, so `stat` answers \"directory\" for it with\n\t * zero store calls. isomorphic-git stats the gitdir on every command\n\t * (`discoverGitdir`); in object storage that is a HEAD that always misses\n\t * plus a listing. Register once the caller has confirmed the repository\n\t * exists by other means (e.g. its database row); `invalidate` forgets it.\n\t */\n\tregisterGitdir(gitdir: string, facts?: GitdirFacts): void;\n}\n\n/**\n * Create a promise-based filesystem client for isomorphic-git backed by an\n * {@link ObjectStore}.\n *\n * Semantics:\n * - Directories are implicit, as in object storage: `mkdir` is a no-op and a\n * directory \"exists\" whenever at least one key lives under its prefix.\n * - Symbolic links are not supported (`readlink`/`symlink` throw). Bare\n * repositories never contain them.\n * - Designed for bare, server-side repositories (`git.init({bare: true})`,\n * plumbing commands, ref updates). Worktree checkouts belong on a real disk.\n */\nexport function createGitFs(\n\tstore: ObjectStore,\n\toptions: GitFsOptions = {},\n): GitFs {\n\tconst prefix = options.prefix ?? \"\";\n\tconst useLooseHints = options.looseObjectHints ?? false;\n\tconst onNote = options.onNote;\n\n\tconst toKey = (path: string): string => toKeyWithPrefix(prefix, path);\n\n\t/**\n\t * Per-gitdir \"does any loose object exist\" hint. Entries are only created\n\t * by {@link GitFs.detectLooseObjects}, so a pathological ref that merely\n\t * looks like a loose object (`refs/heads/objects/aa/…`) derives a scope\n\t * that was never registered and can never be wrongly short-circuited.\n\t */\n\tconst looseHints = new LRUCache<string, \"none\" | \"present\">({\n\t\tmax: 1024,\n\t\tttl: options.hintTtlMs ?? 3_600_000,\n\t});\n\n\t/** Gitdirs the caller vouched for via {@link GitFs.registerGitdir}. */\n\tconst registeredGitdirs = new LRUCache<string, ReadonlySet<string>>({\n\t\tmax: 4096,\n\t});\n\n\t/** Whether `path` is a top-level file its registered gitdir lacks. */\n\tfunction registeredAbsent(path: string): boolean {\n\t\tconst slash = path.lastIndexOf(\"/\");\n\t\tif (slash < 0) return false;\n\t\tconst absent = registeredGitdirs.get(path.slice(0, slash));\n\t\treturn absent?.has(path.slice(slash + 1)) ?? false;\n\t}\n\n\t/** The gitdir scope of a loose-object path, or null when it isn't one. */\n\tfunction looseScope(path: string): string | null {\n\t\treturn parseLooseObjectPath(path)?.gitdir ?? null;\n\t}\n\n\tconst pendingDetections = new Map<string, Promise<void>>();\n\n\t/**\n\t * Resolve the loose-object hint for `path`'s gitdir before answering, so a\n\t * read that runs before any explicit `detectLooseObjects` call (e.g. the\n\t * first commit read of a request) doesn't pay a doomed GET. One coalesced\n\t * listing per gitdir, cached for `hintTtlMs`.\n\t */\n\tasync function knownAbsent(path: string): Promise<boolean> {\n\t\tif (registeredAbsent(path)) return true;\n\t\tif (!useLooseHints) return false;\n\t\tconst scope = looseScope(path);\n\t\tif (scope === null) return false;\n\t\tif (!looseHints.has(scope)) {\n\t\t\tlet pending = pendingDetections.get(scope);\n\t\t\tif (!pending) {\n\t\t\t\tpending = detectLooseObjects(scope).finally(() =>\n\t\t\t\t\tpendingDetections.delete(scope),\n\t\t\t\t);\n\t\t\t\tpendingDetections.set(scope, pending);\n\t\t\t}\n\t\t\tawait pending;\n\t\t}\n\t\treturn looseHints.get(scope) === \"none\";\n\t}\n\n\tasync function isDirectory(dirKey: string): Promise<boolean> {\n\t\tconst { objects, prefixes } = await store.list(`${dirKey}/`, {\n\t\t\tlimit: 1,\n\t\t});\n\t\treturn objects.length > 0 || prefixes.length > 0;\n\t}\n\n\tasync function stat(filepath: string, syscall: string): Promise<Stat> {\n\t\tconst path = normalizePath(filepath);\n\t\tif (await knownAbsent(path)) throw enoent(syscall, filepath);\n\t\tconst k = toKey(path);\n\t\tif (k === prefix || k === \"\" || registeredGitdirs.has(path)) {\n\t\t\treturn makeStat(\"dir\", 0);\n\t\t}\n\t\tconst fileStat = await store.head(k);\n\t\tif (fileStat) return makeStat(\"file\", fileStat.size);\n\t\t// A loose-object path is always a leaf; when the object itself is\n\t\t// absent there is no point probing for a directory of the same name.\n\t\tif (useLooseHints && looseScope(path) !== null) {\n\t\t\tthrow enoent(syscall, filepath);\n\t\t}\n\t\tif (await isDirectory(k)) return makeStat(\"dir\", 0);\n\t\tthrow enoent(syscall, filepath);\n\t}\n\n\tconst promises: GitFsClient[\"promises\"] = {\n\t\tasync readFile(filepath, opts) {\n\t\t\tconst path = normalizePath(filepath);\n\t\t\tif (await knownAbsent(path)) throw enoent(\"open\", filepath);\n\t\t\tconst data = await store.get(toKey(path));\n\t\t\tif (data === null) throw enoent(\"open\", filepath);\n\t\t\treturn resolveEncoding(opts) === \"utf8\" ? textDecoder.decode(data) : data;\n\t\t},\n\n\t\tasync writeFile(filepath, data, _opts) {\n\t\t\tconst path = normalizePath(filepath);\n\t\t\tif (useLooseHints) {\n\t\t\t\tconst scope = looseScope(path);\n\t\t\t\t// Flip before the write lands so a racing read can never\n\t\t\t\t// short-circuit an object that is in the middle of arriving.\n\t\t\t\tif (scope !== null) looseHints.set(scope, \"present\");\n\t\t\t}\n\t\t\tconst bytes = typeof data === \"string\" ? textEncoder.encode(data) : data;\n\t\t\tawait store.put(toKey(path), bytes);\n\t\t},\n\n\t\tasync unlink(filepath) {\n\t\t\tconst k = toKey(normalizePath(filepath));\n\t\t\tif ((await store.head(k)) === null) throw enoent(\"unlink\", filepath);\n\t\t\tawait store.delete(k);\n\t\t},\n\n\t\tasync readdir(dirpath) {\n\t\t\tconst k = toKey(normalizePath(dirpath));\n\t\t\tconst isRoot = k === prefix || k === \"\";\n\t\t\tconst listPrefix = isRoot && k === \"\" ? \"\" : `${k}/`;\n\t\t\tconst { objects, prefixes } = await store.list(listPrefix, {\n\t\t\t\tdelimiter: \"/\",\n\t\t\t});\n\t\t\tif (objects.length === 0 && prefixes.length === 0) {\n\t\t\t\tif (!isRoot && (await store.head(k)) !== null) {\n\t\t\t\t\tthrow enotdir(\"scandir\", dirpath);\n\t\t\t\t}\n\t\t\t\tif (!isRoot) throw enoent(\"scandir\", dirpath);\n\t\t\t}\n\t\t\tconst names = objects.map((o) => o.key.slice(listPrefix.length));\n\t\t\tconst dirNames = prefixes.map((p) =>\n\t\t\t\tp.slice(listPrefix.length).replace(/\\/$/, \"\"),\n\t\t\t);\n\t\t\treturn [...names, ...dirNames].sort();\n\t\t},\n\n\t\tasync mkdir(_dirpath, _opts) {\n\t\t\t// Directories are implicit in object storage.\n\t\t},\n\n\t\tasync rmdir(dirpath) {\n\t\t\tconst k = toKey(normalizePath(dirpath));\n\t\t\tconst { objects, prefixes } = await store.list(`${k}/`, { limit: 1 });\n\t\t\tif (objects.length > 0 || prefixes.length > 0) {\n\t\t\t\tthrow enotempty(\"rmdir\", dirpath);\n\t\t\t}\n\t\t\t// Empty implicit directories don't exist; nothing to remove.\n\t\t},\n\n\t\tstat: (filepath) => stat(filepath, \"stat\"),\n\t\tlstat: (filepath) => stat(filepath, \"lstat\"),\n\n\t\tasync readlink(filepath): Promise<never> {\n\t\t\tthrow enoent(\"readlink\", filepath);\n\t\t},\n\n\t\tasync symlink(_target, filepath): Promise<never> {\n\t\t\tthrow eperm(\"symlink\", filepath);\n\t\t},\n\n\t\tasync chmod(_filepath, _mode) {\n\t\t\t// POSIX modes don't exist in object storage.\n\t\t},\n\t};\n\n\tasync function detectLooseObjects(gitdir: string): Promise<void> {\n\t\tif (!useLooseHints) return;\n\t\tconst scope = normalizePath(gitdir);\n\t\t// A live hint must win over re-detection: after a loose write flips it\n\t\t// to \"present\", re-deriving from a (possibly cached, pre-write) listing\n\t\t// could wrongly reinstate \"none\" and mask real objects.\n\t\tif (looseHints.has(scope)) return;\n\t\ttry {\n\t\t\tconst { objects } = await store.list(`${toKey(scope)}/objects/`, {\n\t\t\t\tlimit: 1,\n\t\t\t});\n\t\t\t// Loose fan-out directories (two hex digits) sort before \"info/\"\n\t\t\t// and \"pack/\", so when any loose object exists it is the first key.\n\t\t\tconst first = objects[0]?.key;\n\t\t\tconst hint =\n\t\t\t\tfirst !== undefined && parseLooseObjectPath(first) !== null\n\t\t\t\t\t? \"present\"\n\t\t\t\t\t: \"none\";\n\t\t\tlooseHints.set(scope, hint);\n\t\t\tonNote?.(`loose objects ${hint} under ${scope}`);\n\t\t} catch {\n\t\t\t// Leave unknown — reads fall back to their normal round trip.\n\t\t}\n\t}\n\n\tasync function prefetchPacks(\n\t\tgitdir: string,\n\t\tprefetchOptions?: { maxPacks?: number },\n\t): Promise<void> {\n\t\tconst maxPacks = prefetchOptions?.maxPacks ?? 30;\n\t\tconst packDir = `${normalizePath(gitdir)}/objects/pack`;\n\t\t// isomorphic-git never reads .bitmap/.rev/.keep, so fetching them is a\n\t\t// wasted GET and wasted cache space.\n\t\tconst entries = parsePackDirectory(\n\t\t\tawait promises.readdir(packDir).catch(() => []),\n\t\t)\n\t\t\t.filter((file) => READABLE_PACK_FILE_KINDS.has(file.kind))\n\t\t\t.map((file) => file.name);\n\t\tif (entries.length > maxPacks * 2) {\n\t\t\tawait detectLooseObjects(gitdir);\n\t\t\treturn;\n\t\t}\n\t\tawait Promise.all([\n\t\t\tdetectLooseObjects(gitdir),\n\t\t\t...entries.map((name) =>\n\t\t\t\tpromises.readFile(`${packDir}/${name}`).catch(() => undefined),\n\t\t\t),\n\t\t]);\n\t}\n\n\tasync function listFilesRecursively(dirpath: string): Promise<string[]> {\n\t\tconst directory = toKey(normalizePath(dirpath));\n\t\tconst listPrefix = directory === \"\" ? \"\" : `${directory}/`;\n\t\tconst { objects } = await store.list(listPrefix);\n\t\treturn objects\n\t\t\t.map((object) => object.key.slice(listPrefix.length))\n\t\t\t.filter((path) => path.length > 0)\n\t\t\t.sort();\n\t}\n\n\tfunction registerGitdir(gitdir: string, facts?: GitdirFacts): void {\n\t\tregisteredGitdirs.set(\n\t\t\tnormalizePath(gitdir),\n\t\t\tnew Set(facts?.absentFiles ?? []),\n\t\t);\n\t}\n\n\tfunction invalidate(pathPrefix: string): void {\n\t\tconst normalized = normalizePath(pathPrefix);\n\t\tfor (const dir of registeredGitdirs.keys()) {\n\t\t\tif (dir.startsWith(normalized)) registeredGitdirs.delete(dir);\n\t\t}\n\t\tfor (const scope of looseHints.keys()) {\n\t\t\tif (scope.startsWith(normalized)) looseHints.delete(scope);\n\t\t}\n\t\tconst maybe = store as ObjectStore & {\n\t\t\tinvalidate?: (prefix: string) => void;\n\t\t};\n\t\tmaybe.invalidate?.(toKey(normalized));\n\t}\n\n\treturn {\n\t\tpromises,\n\t\tlistFilesRecursively,\n\t\tdetectLooseObjects,\n\t\tprefetchPacks,\n\t\tinvalidate,\n\t\tregisterGitdir,\n\t};\n}\n","import { einval } from \"./errors.js\";\n\n/**\n * Normalize an absolute-or-relative filesystem path into a storage key\n * segment: no leading/trailing slashes, `.` segments dropped, `..` resolved.\n * A `..` that would escape the root throws EINVAL — paths handed to the fs\n * must never address keys outside the configured prefix.\n */\nexport function normalizePath(filepath: string): string {\n\tconst segments = filepath.split(\"/\");\n\tconst out: string[] = [];\n\tfor (const segment of segments) {\n\t\tif (segment === \"\" || segment === \".\") continue;\n\t\tif (segment === \"..\") {\n\t\t\tif (out.length === 0) throw einval(\"resolve\", filepath);\n\t\t\tout.pop();\n\t\t\tcontinue;\n\t\t}\n\t\tout.push(segment);\n\t}\n\treturn out.join(\"/\");\n}\n\n/** Join a configured key prefix with a normalized path. */\nexport function toKey(prefix: string, filepath: string): string {\n\tconst normalized = normalizePath(filepath);\n\tif (prefix === \"\") return normalized;\n\treturn normalized === \"\" ? prefix : `${prefix}/${normalized}`;\n}\n","import type { ObjectStore } from \"./types.js\";\n\n/** Options accepted by {@link createRetryStore}. */\nexport interface RetryOptions {\n\t/** Retries after the first attempt (total attempts = retries + 1). Default 3. */\n\tretries?: number;\n\t/** Backoff base delay in milliseconds, doubled each attempt. Default 100. */\n\tinitialDelayMs?: number;\n\t/** Upper bound for the backoff base delay. Default 5000. */\n\tmaxDelayMs?: number;\n\t/** Random jitter added to each delay, as a fraction of it. Default 0.3. */\n\tjitter?: number;\n\t/**\n\t * Decide whether an error is worth retrying. The store contract maps\n\t * \"not found\" to `null` rather than throwing, so any thrown error is a\n\t * genuine failure; the default retries network faults, throttling, and\n\t * HTTP 5xx responses.\n\t */\n\tisRetryable?: (error: unknown) => boolean;\n\t/**\n\t * Circuit breaker configuration, or `false` to disable. After `threshold`\n\t * consecutive failures the store fails fast for `resetMs`, then lets one\n\t * request probe the backend again. Defaults: 5 failures, 30 000 ms.\n\t */\n\tbreaker?: false | { threshold?: number; resetMs?: number };\n\t/** Called before each retry sleep; useful for logging/metrics. */\n\tonRetry?: (info: {\n\t\tkey: string;\n\t\top: string;\n\t\tattempt: number;\n\t\tdelayMs: number;\n\t}) => void;\n}\n\n/**\n * Thrown instead of calling the backend while the circuit breaker is open.\n * Carries `code: \"EUNAVAILABLE\"` so callers can map it to a 503.\n */\nexport class CircuitOpenError extends Error {\n\treadonly code = \"EUNAVAILABLE\";\n\n\tconstructor() {\n\t\tsuper(\"Circuit breaker is open, object store unavailable\");\n\t\tthis.name = \"CircuitOpenError\";\n\t}\n}\n\nconst RETRYABLE_NAMES = new Set([\n\t\"TimeoutError\",\n\t\"RequestTimeout\",\n\t\"RequestTimeoutException\",\n\t\"SlowDown\",\n\t\"ThrottlingException\",\n\t\"TooManyRequestsException\",\n]);\n\nconst RETRYABLE_CODES = new Set([\n\t\"ECONNRESET\",\n\t\"ECONNREFUSED\",\n\t\"EPIPE\",\n\t\"ETIMEDOUT\",\n\t\"ENOTFOUND\",\n\t\"EAI_AGAIN\",\n\t\"EPROTO\",\n]);\n\nfunction defaultIsRetryable(error: unknown): boolean {\n\tif (typeof error !== \"object\" || error === null) return false;\n\tconst err = error as {\n\t\tname?: string;\n\t\tcode?: string;\n\t\t$metadata?: { httpStatusCode?: number };\n\t};\n\tif (err.name !== undefined && RETRYABLE_NAMES.has(err.name)) return true;\n\tif (err.code !== undefined && RETRYABLE_CODES.has(err.code)) return true;\n\tconst status = err.$metadata?.httpStatusCode;\n\treturn status !== undefined && (status >= 500 || status === 429);\n}\n\nconst sleep = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms));\n\n/**\n * Wrap an {@link ObjectStore} with retries (exponential backoff + jitter) and\n * an optional per-instance circuit breaker.\n *\n * Place this decorator closest to the network store, underneath any cache:\n * the cache then never stores transient failures, and callers coalesced onto\n * one request share a single retried attempt.\n */\nexport function createRetryStore(\n\tstore: ObjectStore,\n\toptions: RetryOptions = {},\n): ObjectStore {\n\tconst retries = options.retries ?? 3;\n\tconst initialDelayMs = options.initialDelayMs ?? 100;\n\tconst maxDelayMs = options.maxDelayMs ?? 5000;\n\tconst jitter = options.jitter ?? 0.3;\n\tconst isRetryable = options.isRetryable ?? defaultIsRetryable;\n\tconst breaker =\n\t\toptions.breaker === false\n\t\t\t? null\n\t\t\t: {\n\t\t\t\t\tthreshold: options.breaker?.threshold ?? 5,\n\t\t\t\t\tresetMs: options.breaker?.resetMs ?? 30_000,\n\t\t\t\t};\n\n\tlet failures = 0;\n\tlet lastFailureAt = 0;\n\tlet state: \"closed\" | \"open\" | \"half-open\" = \"closed\";\n\tlet probing = false;\n\n\t/**\n\t * Consecutive transient failures open the circuit; any success closes it\n\t * and resets the count. Non-retryable errors (a 403, a malformed request)\n\t * say nothing about the backend's health and never count. Once the reset\n\t * window passes, exactly one request probes the backend (half-open);\n\t * everything else keeps failing fast until that probe settles.\n\t */\n\tasync function guarded<T>(fn: () => Promise<T>): Promise<T> {\n\t\tif (breaker === null) return fn();\n\t\tlet isProbe = false;\n\t\tif (state !== \"closed\") {\n\t\t\tif (\n\t\t\t\tprobing ||\n\t\t\t\t(state === \"open\" && Date.now() - lastFailureAt < breaker.resetMs)\n\t\t\t) {\n\t\t\t\tthrow new CircuitOpenError();\n\t\t\t}\n\t\t\tstate = \"half-open\";\n\t\t\tprobing = true;\n\t\t\tisProbe = true;\n\t\t}\n\t\ttry {\n\t\t\tconst result = await fn();\n\t\t\tfailures = 0;\n\t\t\tstate = \"closed\";\n\t\t\treturn result;\n\t\t} catch (error) {\n\t\t\tif (isRetryable(error)) {\n\t\t\t\tfailures++;\n\t\t\t\tlastFailureAt = Date.now();\n\t\t\t\tif (failures >= breaker.threshold || isProbe) state = \"open\";\n\t\t\t} else if (isProbe) {\n\t\t\t\t// The backend answered; it's up.\n\t\t\t\tfailures = 0;\n\t\t\t\tstate = \"closed\";\n\t\t\t}\n\t\t\tthrow error;\n\t\t} finally {\n\t\t\tif (isProbe) probing = false;\n\t\t}\n\t}\n\n\tasync function run<T>(op: string, key: string, fn: () => Promise<T>) {\n\t\tlet lastError: unknown;\n\t\tfor (let attempt = 0; attempt <= retries; attempt++) {\n\t\t\ttry {\n\t\t\t\treturn await guarded(fn);\n\t\t\t} catch (error) {\n\t\t\t\tlastError = error;\n\t\t\t\tif (error instanceof CircuitOpenError) throw error;\n\t\t\t\tif (!isRetryable(error) || attempt === retries) throw error;\n\t\t\t\tconst base = Math.min(initialDelayMs * 2 ** attempt, maxDelayMs);\n\t\t\t\tconst delayMs = Math.round(base + Math.random() * base * jitter);\n\t\t\t\toptions.onRetry?.({ key, op, attempt: attempt + 1, delayMs });\n\t\t\t\tawait sleep(delayMs);\n\t\t\t}\n\t\t}\n\t\tthrow lastError;\n\t}\n\n\treturn {\n\t\tget: (key) => run(\"get\", key, () => store.get(key)),\n\t\tput: (key, data) => run(\"put\", key, () => store.put(key, data)),\n\t\tdelete: (key) => run(\"delete\", key, () => store.delete(key)),\n\t\thead: (key) => run(\"head\", key, () => store.head(key)),\n\t\tlist: (prefix, listOptions) =>\n\t\t\trun(\"list\", prefix, () => store.list(prefix, listOptions)),\n\t};\n}\n","import type {\n\tListOptions,\n\tListResult,\n\tObjectStat,\n\tObjectStore,\n} from \"../types.js\";\n\n/**\n * In-memory {@link ObjectStore}. Useful for tests, examples, and ephemeral\n * repositories; also the reference implementation for the list/delimiter\n * semantics other stores must match.\n */\nexport class MemoryObjectStore implements ObjectStore {\n\tprivate readonly objects = new Map<string, Uint8Array>();\n\n\tasync get(key: string): Promise<Uint8Array | null> {\n\t\tconst data = this.objects.get(key);\n\t\treturn data ? data.slice() : null;\n\t}\n\n\tasync put(key: string, data: Uint8Array): Promise<void> {\n\t\tthis.objects.set(key, data.slice());\n\t}\n\n\tasync delete(key: string): Promise<void> {\n\t\tthis.objects.delete(key);\n\t}\n\n\tasync head(key: string): Promise<ObjectStat | null> {\n\t\tconst data = this.objects.get(key);\n\t\treturn data ? { size: data.byteLength } : null;\n\t}\n\n\tasync list(prefix: string, options?: ListOptions): Promise<ListResult> {\n\t\tconst delimiter = options?.delimiter;\n\t\tconst limit = options?.limit ?? Number.POSITIVE_INFINITY;\n\t\tconst objects: ListResult[\"objects\"] = [];\n\t\tconst prefixes = new Set<string>();\n\n\t\tfor (const [key, data] of this.objects) {\n\t\t\tif (!key.startsWith(prefix)) continue;\n\t\t\tconst rest = key.slice(prefix.length);\n\t\t\tif (delimiter !== undefined) {\n\t\t\t\tconst idx = rest.indexOf(delimiter);\n\t\t\t\tif (idx !== -1) {\n\t\t\t\t\tprefixes.add(prefix + rest.slice(0, idx + delimiter.length));\n\t\t\t\t} else {\n\t\t\t\t\tobjects.push({ key, size: data.byteLength });\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tobjects.push({ key, size: data.byteLength });\n\t\t\t}\n\t\t\tif (objects.length + prefixes.size >= limit) break;\n\t\t}\n\n\t\treturn { objects, prefixes: [...prefixes] };\n\t}\n\n\t/** Number of stored objects (test convenience, not part of ObjectStore). */\n\tget size(): number {\n\t\treturn this.objects.size;\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,gBAAgB;AA8EzB,IAAM,OAAO,uBAAO,MAAM;AAa1B,SAAS,cAAc,OAA0B;AAChD,MAAI,OAAO,MAAM,OAAO,SAAS;AACjC,aAAW,KAAK,MAAM,OAAO,QAAS,SAAQ,EAAE,IAAI,SAAS;AAC7D,aAAW,KAAK,MAAM,OAAO,SAAU,SAAQ,EAAE;AACjD,SAAO;AACR;AAEA,SAAS,eAAe,QAAgC;AACvD,SAAO;AAAA,IACN,SAAS,OAAO,QAAQ,IAAI,CAAC,OAAO,EAAE,GAAG,EAAE,EAAE;AAAA,IAC7C,UAAU,CAAC,GAAG,OAAO,QAAQ;AAAA,EAC9B;AACD;AAaO,SAAS,kBACf,OACA,UAAwB,CAAC,GACL;AACpB,QAAM,WAAW,QAAQ,YAAY,KAAK,OAAO;AACjD,QAAM,gBAAgB,QAAQ,iBAAiB,KAAK,KAAK,WAAW,EAAE;AACtE,QAAM,MAAM,QAAQ,SAAS;AAC7B,QAAM,YAAY,QAAQ;AAC1B,QAAM,cAAc,QAAQ,eAAe;AAC3C,QAAM,aAAa,QAAQ,cAAc;AACzC,QAAM,WAAW,QAAQ,YAAY;AACrC,QAAM,OAAO,QAAQ,QAAQ;AAC7B,Q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,OAAO;AACN,gBAAQ,KAAK,EAAE,KAAK,MAAM,KAAK,WAAW,CAAC;AAAA,MAC5C;AACA,UAAI,QAAQ,SAAS,SAAS,QAAQ,MAAO;AAAA,IAC9C;AAEA,WAAO,EAAE,SAAS,UAAU,CAAC,GAAG,QAAQ,EAAE;AAAA,EAC3C;AAAA;AAAA,EAGA,IAAI,OAAe;AAClB,WAAO,KAAK,QAAQ;AAAA,EACrB;AACD;","names":["LRUCache","toKey","LRUCache"]}
|
|
1
|
+
{"version":3,"sources":["../src/cache.ts","../src/errors.ts","../src/git-fs.ts","../src/path.ts","../src/retry.ts","../src/stores/memory.ts"],"sourcesContent":["import { LRUCache } from \"lru-cache\";\nimport type {\n\tListOptions,\n\tListResult,\n\tObjectStat,\n\tObjectStore,\n} from \"./types.js\";\n\nexport interface CacheOptions {\n\t/** Maximum bytes of object data held in memory. Default 50 MiB. */\n\tmaxBytes?: number;\n\t/**\n\t * Largest single entry admitted to the cache. Defaults to a tenth of\n\t * `maxBytes` so one huge packfile cannot evict the whole working set.\n\t */\n\tmaxEntryBytes?: number;\n\t/** Entry time-to-live in milliseconds. Default 60 000. */\n\tttlMs?: number;\n\t/**\n\t * Override the TTL for a specific key (get/head) or list prefix (list),\n\t * in milliseconds. Return `undefined` to fall back to `ttlMs`. Git refs\n\t * (`refs/heads/<branch>`, `HEAD`) are mutable — the same key's value\n\t * changes on every push — unlike content-addressed object keys, which\n\t * never change for a given key and are safe to cache for the full\n\t * `ttlMs`. Without this, a long `ttlMs` tuned for objects also caches\n\t * ref reads that long, so a warm process can keep serving a\n\t * pre-push ref value for the rest of that TTL even though nothing\n\t * changed *this* process's own cache (see `invalidate`) — it just never\n\t * knew to. Give ref-like keys a short override (a few seconds) instead:\n\t * a ref read is one small object, so re-reading it far more often than\n\t * `ttlMs` is cheap, and every read downstream of a fresh ref (tree,\n\t * commit, blob — all keyed by the sha it resolves to) still gets the\n\t * full-length cache/coalescing benefit.\n\t */\n\tttlForKey?: (key: string) => number | undefined;\n\t/**\n\t * Also cache \"key does not exist\" results. Loose-object probes on packed\n\t * repositories are almost always misses, so this saves many round trips —\n\t * but only enable it when a single process is the only writer, otherwise\n\t * another instance's push can be masked for up to `ttlMs`.\n\t */\n\tcacheMisses?: boolean;\n\t/**\n\t * Also cache `list()` results (directory listings and `limit: 1`\n\t * existence probes). Writes through this store keep cached listings\n\t * consistent; after writing to the backend by any other means, call\n\t * `invalidate()` with the affected prefix. Default false.\n\t */\n\tcacheLists?: boolean;\n\t/**\n\t * Collapse concurrent `get`/`head`/`list` calls for the same key into a\n\t * single backend request. Default true.\n\t */\n\tcoalesce?: boolean;\n\t/**\n\t * Return defensive copies from `get` (and copy on admit), so a caller\n\t * mutating returned bytes can't corrupt the cache. Default true. Set\n\t * false when no reader mutates results (isomorphic-git doesn't): every\n\t * hit otherwise copies the whole entry, which for packfiles is megabytes\n\t * per read.\n\t */\n\tcopy?: boolean;\n\t/** Called when a read is answered from cache. */\n\tonHit?: (key: string) => void;\n\t/** Called when a read has to go to the backing store. */\n\tonMiss?: (key: string) => void;\n}\n\n/** An {@link ObjectStore} wrapper that also supports explicit invalidation. */\nexport interface CachedObjectStore extends ObjectStore {\n\t/**\n\t * Drop every cached entry — contents, misses, and listings — whose key\n\t * falls under `prefix` (exact keys included). Call this after the backing\n\t * store was modified by something other than this wrapper.\n\t */\n\tinvalidate(prefix: string): void;\n}\n\nconst MISS = Symbol(\"miss\");\ntype CacheEntry = Uint8Array | typeof MISS;\n\ninterface ListEntry {\n\tresult: ListResult;\n\t/** The raw list prefix this entry describes. */\n\tprefix: string;\n\t/** True for `limit: 1` existence probes. */\n\tprobe: boolean;\n\t/** True when the listing came back with no objects or prefixes. */\n\tempty: boolean;\n}\n\nfunction listEntrySize(entry: ListEntry): number {\n\tlet size = entry.prefix.length + 16;\n\tfor (const o of entry.result.objects) size += o.key.length + 8;\n\tfor (const p of entry.result.prefixes) size += p.length;\n\treturn size;\n}\n\nfunction copyListResult(result: ListResult): ListResult {\n\treturn {\n\t\tobjects: result.objects.map((o) => ({ ...o })),\n\t\tprefixes: [...result.prefixes],\n\t};\n}\n\n/**\n * Wrap an {@link ObjectStore} with an in-process LRU read cache.\n *\n * Git object keys are content-addressed and therefore immutable, which makes\n * them ideal cache entries; mutable keys (refs, packed-refs) are bounded by\n * `ttlMs`. Writes and deletes through this wrapper invalidate their key and\n * any cached listings they affect — with one asymmetry: a non-empty `limit: 1`\n * probe (a \"directory exists\" answer) survives writes underneath it, because\n * adding a key below a prefix cannot make that prefix stop existing, while\n * empty probes and full listings are always dropped.\n */\nexport function createCachedStore(\n\tstore: ObjectStore,\n\toptions: CacheOptions = {},\n): CachedObjectStore {\n\tconst maxBytes = options.maxBytes ?? 50 * 1024 * 1024;\n\tconst maxEntryBytes = options.maxEntryBytes ?? Math.ceil(maxBytes / 10);\n\tconst ttl = options.ttlMs ?? 60_000;\n\tconst ttlForKey = options.ttlForKey;\n\tconst cacheMisses = options.cacheMisses ?? false;\n\tconst cacheLists = options.cacheLists ?? false;\n\tconst range = store.getRange?.bind(store);\n\tconst coalesce = options.coalesce ?? true;\n\tconst copy = options.copy ?? true;\n\tconst clone = (data: Uint8Array) => (copy ? data.slice() : data);\n\tconst onHit = options.onHit;\n\tconst onMiss = options.onMiss;\n\n\tconst cache = new LRUCache<string, CacheEntry>({\n\t\tmaxSize: maxBytes,\n\t\tsizeCalculation: (value) => (value === MISS ? 1 : value.byteLength || 1),\n\t\tttl,\n\t});\n\tconst listCache = new LRUCache<string, ListEntry>({\n\t\tmaxSize: Math.max(1, Math.ceil(maxBytes / 10)),\n\t\tsizeCalculation: listEntrySize,\n\t\tttl,\n\t});\n\n\tconst pendingGets = new Map<string, Promise<Uint8Array | null>>();\n\tconst pendingHeads = new Map<string, Promise<ObjectStat | null>>();\n\tconst pendingLists = new Map<string, Promise<ListResult>>();\n\n\t/**\n\t * Bumped by every write, delete and invalidation. A backend read that\n\t * started before one of those may finish after it carrying the old answer\n\t * (the old bytes, or \"missing\" for a key that now exists); it still\n\t * answers its own callers, but only a read that saw no write in between\n\t * may populate the cache — otherwise a stale miss could hide a freshly\n\t * written object for the whole TTL.\n\t */\n\tlet generation = 0;\n\tconst unchangedSince = (start: number) => generation === start;\n\n\tconst admit = (key: string, data: Uint8Array) => {\n\t\tif (data.byteLength <= maxEntryBytes) {\n\t\t\tcache.set(key, clone(data), { ttl: ttlForKey?.(key) });\n\t\t}\n\t};\n\n\t/** Drop list entries a write/delete at `key` may have made stale. */\n\tfunction clearStaleListEntries(key: string): void {\n\t\tfor (const [listKey, entry] of listCache.entries()) {\n\t\t\tif (!key.startsWith(entry.prefix)) continue;\n\t\t\tif (entry.probe && !entry.empty) continue;\n\t\t\tlistCache.delete(listKey);\n\t\t}\n\t\t// Readers arriving after this write must not join a listing that\n\t\t// started before it.\n\t\tfor (const listKey of pendingLists.keys()) {\n\t\t\tconst prefix = listKey.split(\"|\").slice(2).join(\"|\");\n\t\t\tif (key.startsWith(prefix)) pendingLists.delete(listKey);\n\t\t}\n\t}\n\n\t/** A write to `key` happened: no in-flight read of it may be joined or cached. */\n\tfunction noteWrite(key: string): void {\n\t\tgeneration++;\n\t\tpendingGets.delete(key);\n\t\tpendingHeads.delete(key);\n\t}\n\n\tfunction coalesced<T>(\n\t\tpending: Map<string, Promise<T>>,\n\t\tkey: string,\n\t\tfn: () => Promise<T>,\n\t): Promise<T> {\n\t\tif (!coalesce) return fn();\n\t\tconst inflight = pending.get(key);\n\t\tif (inflight !== undefined) return inflight;\n\t\tconst p = fn().finally(() => {\n\t\t\tif (pending.get(key) === p) pending.delete(key);\n\t\t});\n\t\tpending.set(key, p);\n\t\treturn p;\n\t}\n\n\treturn {\n\t\tasync get(key: string): Promise<Uint8Array | null> {\n\t\t\tconst cached = cache.get(key);\n\t\t\tif (cached !== undefined) {\n\t\t\t\tonHit?.(key);\n\t\t\t\treturn cached === MISS ? null : clone(cached);\n\t\t\t}\n\t\t\tconst data = await coalesced(pendingGets, key, async () => {\n\t\t\t\tonMiss?.(key);\n\t\t\t\tconst start = generation;\n\t\t\t\tconst fetched = await store.get(key);\n\t\t\t\tif (unchangedSince(start)) {\n\t\t\t\t\tif (fetched !== null) {\n\t\t\t\t\t\tadmit(key, fetched);\n\t\t\t\t\t} else if (cacheMisses) {\n\t\t\t\t\t\tcache.set(key, MISS, { ttl: ttlForKey?.(key) });\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn fetched;\n\t\t\t});\n\t\t\treturn data === null ? null : clone(data);\n\t\t},\n\n\t\tasync put(key: string, data: Uint8Array): Promise<void> {\n\t\t\tnoteWrite(key);\n\t\t\ttry {\n\t\t\t\tawait store.put(key, data);\n\t\t\t} finally {\n\t\t\t\t// Even a failed put may have landed; never keep serving the\n\t\t\t\t// pre-write answer for this key.\n\t\t\t\tnoteWrite(key);\n\t\t\t\tcache.delete(key);\n\t\t\t\tclearStaleListEntries(key);\n\t\t\t}\n\t\t\tadmit(key, data);\n\t\t},\n\n\t\tasync delete(key: string): Promise<void> {\n\t\t\tnoteWrite(key);\n\t\t\ttry {\n\t\t\t\tawait store.delete(key);\n\t\t\t} finally {\n\t\t\t\tnoteWrite(key);\n\t\t\t\tcache.delete(key);\n\t\t\t\tclearStaleListEntries(key);\n\t\t\t}\n\t\t\tif (cacheMisses) {\n\t\t\t\tcache.set(key, MISS, { ttl: ttlForKey?.(key) });\n\t\t\t} else {\n\t\t\t\tcache.delete(key);\n\t\t\t}\n\t\t},\n\n\t\tasync head(key: string): Promise<ObjectStat | null> {\n\t\t\tconst cached = cache.get(key);\n\t\t\tif (cached !== undefined) {\n\t\t\t\tonHit?.(key);\n\t\t\t\treturn cached === MISS ? null : { size: cached.byteLength };\n\t\t\t}\n\t\t\treturn coalesced(pendingHeads, key, async () => {\n\t\t\t\tonMiss?.(key);\n\t\t\t\tconst start = generation;\n\t\t\t\tconst stat = await store.head(key);\n\t\t\t\tif (stat === null && cacheMisses && unchangedSince(start)) {\n\t\t\t\t\tcache.set(key, MISS, { ttl: ttlForKey?.(key) });\n\t\t\t\t}\n\t\t\t\treturn stat;\n\t\t\t});\n\t\t},\n\n\t\tasync list(prefix: string, listOptions?: ListOptions): Promise<ListResult> {\n\t\t\tif (!cacheLists) return store.list(prefix, listOptions);\n\t\t\tconst listKey = `${listOptions?.delimiter ?? \"\"}|${listOptions?.limit ?? \"\"}|${prefix}`;\n\t\t\tconst cached = listCache.get(listKey);\n\t\t\tif (cached !== undefined) {\n\t\t\t\tonHit?.(prefix);\n\t\t\t\treturn copyListResult(cached.result);\n\t\t\t}\n\t\t\tconst result = await coalesced(pendingLists, listKey, async () => {\n\t\t\t\tonMiss?.(prefix);\n\t\t\t\tconst start = generation;\n\t\t\t\tconst fetched = await store.list(prefix, listOptions);\n\t\t\t\tif (!unchangedSince(start)) return fetched;\n\t\t\t\tlistCache.set(\n\t\t\t\t\tlistKey,\n\t\t\t\t\t{\n\t\t\t\t\t\tresult: copyListResult(fetched),\n\t\t\t\t\t\tprefix,\n\t\t\t\t\t\tprobe: listOptions?.limit === 1,\n\t\t\t\t\t\tempty:\n\t\t\t\t\t\t\tfetched.objects.length === 0 && fetched.prefixes.length === 0,\n\t\t\t\t\t},\n\t\t\t\t\t{ ttl: ttlForKey?.(prefix) },\n\t\t\t\t);\n\t\t\t\treturn fetched;\n\t\t\t});\n\t\t\treturn copyListResult(result);\n\t\t},\n\n\t\t// Forwarded straight to the backing store: a range read is a handful of\n\t\t// bytes at a known offset, so caching one buys nothing, and bypassing the\n\t\t// cache here keeps this wrapper's read paths unchanged.\n\t\t...(range\n\t\t\t? {\n\t\t\t\t\tgetRange: (key: string, start: number, end: number) =>\n\t\t\t\t\t\trange(key, start, end),\n\t\t\t\t}\n\t\t\t: {}),\n\n\t\tinvalidate(prefix: string): void {\n\t\t\tgeneration++;\n\t\t\tfor (const key of [...pendingGets.keys()]) {\n\t\t\t\tif (key.startsWith(prefix)) pendingGets.delete(key);\n\t\t\t}\n\t\t\tfor (const key of [...pendingHeads.keys()]) {\n\t\t\t\tif (key.startsWith(prefix)) pendingHeads.delete(key);\n\t\t\t}\n\t\t\tpendingLists.clear();\n\t\t\tfor (const key of cache.keys()) {\n\t\t\t\tif (key.startsWith(prefix)) cache.delete(key);\n\t\t\t}\n\t\t\tfor (const [listKey, entry] of listCache.entries()) {\n\t\t\t\tif (\n\t\t\t\t\tentry.prefix.startsWith(prefix) ||\n\t\t\t\t\tprefix.startsWith(entry.prefix)\n\t\t\t\t) {\n\t\t\t\t\tlistCache.delete(listKey);\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t};\n}\n","/**\n * Node-style filesystem error carrying a `code` property, which is what\n * isomorphic-git inspects to distinguish \"file not found\" from real failures.\n */\nexport class FsError extends Error {\n\treadonly code: string;\n\treadonly syscall: string;\n\treadonly path: string;\n\n\tconstructor(code: string, syscall: string, path: string) {\n\t\tsuper(`${code}: ${syscall} '${path}'`);\n\t\tthis.name = \"FsError\";\n\t\tthis.code = code;\n\t\tthis.syscall = syscall;\n\t\tthis.path = path;\n\t}\n}\n\nexport const enoent = (syscall: string, path: string) =>\n\tnew FsError(\"ENOENT\", syscall, path);\n\nexport const enotdir = (syscall: string, path: string) =>\n\tnew FsError(\"ENOTDIR\", syscall, path);\n\nexport const enotempty = (syscall: string, path: string) =>\n\tnew FsError(\"ENOTEMPTY\", syscall, path);\n\nexport const einval = (syscall: string, path: string) =>\n\tnew FsError(\"EINVAL\", syscall, path);\n\nexport const eperm = (syscall: string, path: string) =>\n\tnew FsError(\"EPERM\", syscall, path);\n","import { LRUCache } from \"lru-cache\";\nimport { enoent, enotdir, enotempty, eperm } from \"./errors.js\";\nimport { parseLooseObjectPath } from \"./git-layout.js\";\nimport { parsePackDirectory, READABLE_PACK_FILE_KINDS } from \"./pack-files.js\";\nimport { normalizePath, toKey as toKeyWithPrefix } from \"./path.js\";\nimport type {\n\tEncoding,\n\tGitdirFacts,\n\tGitFsClient,\n\tGitFsOptions,\n\tObjectStore,\n\tReadFileOptions,\n\tStat,\n\tWriteFileOptions,\n} from \"./types.js\";\n\nconst FILE_MODE = 0o100644;\nconst DIR_MODE = 0o40000;\n\nconst textEncoder = new TextEncoder();\nconst textDecoder = new TextDecoder();\n\nfunction makeStat(type: \"file\" | \"dir\", size: number): Stat {\n\tconst epoch = new Date(0);\n\treturn {\n\t\ttype,\n\t\tmode: type === \"file\" ? FILE_MODE : DIR_MODE,\n\t\tsize,\n\t\tino: 0,\n\t\tmtimeMs: 0,\n\t\tctimeMs: 0,\n\t\tuid: 0,\n\t\tgid: 0,\n\t\tdev: 0,\n\t\tmtime: epoch,\n\t\tctime: epoch,\n\t\tisFile: () => type === \"file\",\n\t\tisDirectory: () => type === \"dir\",\n\t\tisSymbolicLink: () => false,\n\t};\n}\n\nfunction resolveEncoding(\n\toptions?: ReadFileOptions | WriteFileOptions | Encoding,\n): Encoding | undefined {\n\tif (typeof options === \"string\") return options;\n\treturn options?.encoding;\n}\n\n/**\n * The filesystem returned by {@link createGitFs}: the isomorphic-git client\n * plus git-aware maintenance hooks.\n */\nexport interface GitFs extends GitFsClient {\n\t/**\n\t * Return every file below a directory in one object-store listing. Unlike\n\t * `readdir`, this deliberately does not use a delimiter: object storage can\n\t * enumerate a ref namespace recursively without the stat-per-entry walk a\n\t * POSIX filesystem needs to distinguish files from implicit directories.\n\t * Paths are relative to `dirpath` and never include directory entries.\n\t */\n\tlistFilesRecursively(dirpath: string): Promise<string[]>;\n\t/**\n\t * Probe, with one bounded list, whether `gitdir` contains any loose\n\t * objects, and remember the answer. This is the only way a loose-object\n\t * hint is ever created; call it before full-history walks (commit logs,\n\t * reachability traversals) so fully packed repositories skip every\n\t * guaranteed-miss loose-object read. A later loose write flips the hint\n\t * back, so it cannot go stale mid-push.\n\t */\n\tdetectLooseObjects(gitdir: string): Promise<void>;\n\t/**\n\t * Warm the cache with every pack file under `gitdir` in parallel (plus\n\t * the loose-object hint) before a sequential history walk. Skipped when\n\t * the pack directory holds more than `maxPacks * 2` entries — warming\n\t * only helps when the cache budget actually fits the packs.\n\t */\n\tprefetchPacks(gitdir: string, options?: { maxPacks?: number }): Promise<void>;\n\t/**\n\t * Clear fs-level state (loose-object hints) under `pathPrefix`, and\n\t * forward to the store's `invalidate` when it has one. Call after the\n\t * backing store was modified by something other than this fs.\n\t */\n\tinvalidate(pathPrefix: string): void;\n\t/**\n\t * Declare that `gitdir` exists, so `stat` answers \"directory\" for it with\n\t * zero store calls. isomorphic-git stats the gitdir on every command\n\t * (`discoverGitdir`); in object storage that is a HEAD that always misses\n\t * plus a listing. Register once the caller has confirmed the repository\n\t * exists by other means (e.g. its database row); `invalidate` forgets it.\n\t */\n\tregisterGitdir(gitdir: string, facts?: GitdirFacts): void;\n}\n\n/**\n * Create a promise-based filesystem client for isomorphic-git backed by an\n * {@link ObjectStore}.\n *\n * Semantics:\n * - Directories are implicit, as in object storage: `mkdir` is a no-op and a\n * directory \"exists\" whenever at least one key lives under its prefix.\n * - Symbolic links are not supported (`readlink`/`symlink` throw). Bare\n * repositories never contain them.\n * - Designed for bare, server-side repositories (`git.init({bare: true})`,\n * plumbing commands, ref updates). Worktree checkouts belong on a real disk.\n */\nexport function createGitFs(\n\tstore: ObjectStore,\n\toptions: GitFsOptions = {},\n): GitFs {\n\tconst prefix = options.prefix ?? \"\";\n\tconst useLooseHints = options.looseObjectHints ?? false;\n\tconst onNote = options.onNote;\n\n\tconst toKey = (path: string): string => toKeyWithPrefix(prefix, path);\n\n\t/**\n\t * Per-gitdir \"does any loose object exist\" hint. Entries are only created\n\t * by {@link GitFs.detectLooseObjects}, so a pathological ref that merely\n\t * looks like a loose object (`refs/heads/objects/aa/…`) derives a scope\n\t * that was never registered and can never be wrongly short-circuited.\n\t */\n\tconst looseHints = new LRUCache<string, \"none\" | \"present\">({\n\t\tmax: 1024,\n\t\tttl: options.hintTtlMs ?? 3_600_000,\n\t});\n\n\t/** Gitdirs the caller vouched for via {@link GitFs.registerGitdir}. */\n\tconst registeredGitdirs = new LRUCache<string, ReadonlySet<string>>({\n\t\tmax: 4096,\n\t});\n\n\t/** Whether `path` is a top-level file its registered gitdir lacks. */\n\tfunction registeredAbsent(path: string): boolean {\n\t\tconst slash = path.lastIndexOf(\"/\");\n\t\tif (slash < 0) return false;\n\t\tconst absent = registeredGitdirs.get(path.slice(0, slash));\n\t\treturn absent?.has(path.slice(slash + 1)) ?? false;\n\t}\n\n\t/** The gitdir scope of a loose-object path, or null when it isn't one. */\n\tfunction looseScope(path: string): string | null {\n\t\treturn parseLooseObjectPath(path)?.gitdir ?? null;\n\t}\n\n\tconst pendingDetections = new Map<string, Promise<void>>();\n\n\t/**\n\t * Resolve the loose-object hint for `path`'s gitdir before answering, so a\n\t * read that runs before any explicit `detectLooseObjects` call (e.g. the\n\t * first commit read of a request) doesn't pay a doomed GET. One coalesced\n\t * listing per gitdir, cached for `hintTtlMs`.\n\t */\n\tasync function knownAbsent(path: string): Promise<boolean> {\n\t\tif (registeredAbsent(path)) return true;\n\t\tif (!useLooseHints) return false;\n\t\tconst scope = looseScope(path);\n\t\tif (scope === null) return false;\n\t\tif (!looseHints.has(scope)) {\n\t\t\tlet pending = pendingDetections.get(scope);\n\t\t\tif (!pending) {\n\t\t\t\tpending = detectLooseObjects(scope).finally(() =>\n\t\t\t\t\tpendingDetections.delete(scope),\n\t\t\t\t);\n\t\t\t\tpendingDetections.set(scope, pending);\n\t\t\t}\n\t\t\tawait pending;\n\t\t}\n\t\treturn looseHints.get(scope) === \"none\";\n\t}\n\n\tasync function isDirectory(dirKey: string): Promise<boolean> {\n\t\tconst { objects, prefixes } = await store.list(`${dirKey}/`, {\n\t\t\tlimit: 1,\n\t\t});\n\t\treturn objects.length > 0 || prefixes.length > 0;\n\t}\n\n\tasync function stat(filepath: string, syscall: string): Promise<Stat> {\n\t\tconst path = normalizePath(filepath);\n\t\tif (await knownAbsent(path)) throw enoent(syscall, filepath);\n\t\tconst k = toKey(path);\n\t\tif (k === prefix || k === \"\" || registeredGitdirs.has(path)) {\n\t\t\treturn makeStat(\"dir\", 0);\n\t\t}\n\t\tconst fileStat = await store.head(k);\n\t\tif (fileStat) return makeStat(\"file\", fileStat.size);\n\t\t// A loose-object path is always a leaf; when the object itself is\n\t\t// absent there is no point probing for a directory of the same name.\n\t\tif (useLooseHints && looseScope(path) !== null) {\n\t\t\tthrow enoent(syscall, filepath);\n\t\t}\n\t\tif (await isDirectory(k)) return makeStat(\"dir\", 0);\n\t\tthrow enoent(syscall, filepath);\n\t}\n\n\tconst range = store.getRange?.bind(store);\n\n\tconst promises: GitFsClient[\"promises\"] = {\n\t\t// Only defined when the backing store supports ranges, so a caller can\n\t\t// test for it rather than have to interpret a failure.\n\t\t...(range\n\t\t\t? {\n\t\t\t\t\tgetRange: (filepath: string, start: number, end: number) =>\n\t\t\t\t\t\trange(toKey(normalizePath(filepath)), start, end),\n\t\t\t\t}\n\t\t\t: {}),\n\n\t\tasync readFile(filepath, opts) {\n\t\t\tconst path = normalizePath(filepath);\n\t\t\tif (await knownAbsent(path)) throw enoent(\"open\", filepath);\n\t\t\tconst data = await store.get(toKey(path));\n\t\t\tif (data === null) throw enoent(\"open\", filepath);\n\t\t\treturn resolveEncoding(opts) === \"utf8\" ? textDecoder.decode(data) : data;\n\t\t},\n\n\t\tasync writeFile(filepath, data, _opts) {\n\t\t\tconst path = normalizePath(filepath);\n\t\t\tif (useLooseHints) {\n\t\t\t\tconst scope = looseScope(path);\n\t\t\t\t// Flip before the write lands so a racing read can never\n\t\t\t\t// short-circuit an object that is in the middle of arriving.\n\t\t\t\tif (scope !== null) looseHints.set(scope, \"present\");\n\t\t\t}\n\t\t\tconst bytes = typeof data === \"string\" ? textEncoder.encode(data) : data;\n\t\t\tawait store.put(toKey(path), bytes);\n\t\t},\n\n\t\tasync unlink(filepath) {\n\t\t\tconst k = toKey(normalizePath(filepath));\n\t\t\tif ((await store.head(k)) === null) throw enoent(\"unlink\", filepath);\n\t\t\tawait store.delete(k);\n\t\t},\n\n\t\tasync readdir(dirpath) {\n\t\t\tconst k = toKey(normalizePath(dirpath));\n\t\t\tconst isRoot = k === prefix || k === \"\";\n\t\t\tconst listPrefix = isRoot && k === \"\" ? \"\" : `${k}/`;\n\t\t\tconst { objects, prefixes } = await store.list(listPrefix, {\n\t\t\t\tdelimiter: \"/\",\n\t\t\t});\n\t\t\tif (objects.length === 0 && prefixes.length === 0) {\n\t\t\t\tif (!isRoot && (await store.head(k)) !== null) {\n\t\t\t\t\tthrow enotdir(\"scandir\", dirpath);\n\t\t\t\t}\n\t\t\t\tif (!isRoot) throw enoent(\"scandir\", dirpath);\n\t\t\t}\n\t\t\tconst names = objects.map((o) => o.key.slice(listPrefix.length));\n\t\t\tconst dirNames = prefixes.map((p) =>\n\t\t\t\tp.slice(listPrefix.length).replace(/\\/$/, \"\"),\n\t\t\t);\n\t\t\treturn [...names, ...dirNames].sort();\n\t\t},\n\n\t\tasync mkdir(_dirpath, _opts) {\n\t\t\t// Directories are implicit in object storage.\n\t\t},\n\n\t\tasync rmdir(dirpath) {\n\t\t\tconst k = toKey(normalizePath(dirpath));\n\t\t\tconst { objects, prefixes } = await store.list(`${k}/`, { limit: 1 });\n\t\t\tif (objects.length > 0 || prefixes.length > 0) {\n\t\t\t\tthrow enotempty(\"rmdir\", dirpath);\n\t\t\t}\n\t\t\t// Empty implicit directories don't exist; nothing to remove.\n\t\t},\n\n\t\tstat: (filepath) => stat(filepath, \"stat\"),\n\t\tlstat: (filepath) => stat(filepath, \"lstat\"),\n\n\t\tasync readlink(filepath): Promise<never> {\n\t\t\tthrow enoent(\"readlink\", filepath);\n\t\t},\n\n\t\tasync symlink(_target, filepath): Promise<never> {\n\t\t\tthrow eperm(\"symlink\", filepath);\n\t\t},\n\n\t\tasync chmod(_filepath, _mode) {\n\t\t\t// POSIX modes don't exist in object storage.\n\t\t},\n\t};\n\n\tasync function detectLooseObjects(gitdir: string): Promise<void> {\n\t\tif (!useLooseHints) return;\n\t\tconst scope = normalizePath(gitdir);\n\t\t// A live hint must win over re-detection: after a loose write flips it\n\t\t// to \"present\", re-deriving from a (possibly cached, pre-write) listing\n\t\t// could wrongly reinstate \"none\" and mask real objects.\n\t\tif (looseHints.has(scope)) return;\n\t\ttry {\n\t\t\tconst { objects } = await store.list(`${toKey(scope)}/objects/`, {\n\t\t\t\tlimit: 1,\n\t\t\t});\n\t\t\t// Loose fan-out directories (two hex digits) sort before \"info/\"\n\t\t\t// and \"pack/\", so when any loose object exists it is the first key.\n\t\t\tconst first = objects[0]?.key;\n\t\t\tconst hint =\n\t\t\t\tfirst !== undefined && parseLooseObjectPath(first) !== null\n\t\t\t\t\t? \"present\"\n\t\t\t\t\t: \"none\";\n\t\t\tlooseHints.set(scope, hint);\n\t\t\tonNote?.(`loose objects ${hint} under ${scope}`);\n\t\t} catch {\n\t\t\t// Leave unknown — reads fall back to their normal round trip.\n\t\t}\n\t}\n\n\tasync function prefetchPacks(\n\t\tgitdir: string,\n\t\tprefetchOptions?: { maxPacks?: number },\n\t): Promise<void> {\n\t\tconst maxPacks = prefetchOptions?.maxPacks ?? 30;\n\t\tconst packDir = `${normalizePath(gitdir)}/objects/pack`;\n\t\t// isomorphic-git never reads .bitmap/.rev/.keep, so fetching them is a\n\t\t// wasted GET and wasted cache space.\n\t\tconst entries = parsePackDirectory(\n\t\t\tawait promises.readdir(packDir).catch(() => []),\n\t\t)\n\t\t\t.filter((file) => READABLE_PACK_FILE_KINDS.has(file.kind))\n\t\t\t.map((file) => file.name);\n\t\tif (entries.length > maxPacks * 2) {\n\t\t\tawait detectLooseObjects(gitdir);\n\t\t\treturn;\n\t\t}\n\t\tawait Promise.all([\n\t\t\tdetectLooseObjects(gitdir),\n\t\t\t...entries.map((name) =>\n\t\t\t\tpromises.readFile(`${packDir}/${name}`).catch(() => undefined),\n\t\t\t),\n\t\t]);\n\t}\n\n\tasync function listFilesRecursively(dirpath: string): Promise<string[]> {\n\t\tconst directory = toKey(normalizePath(dirpath));\n\t\tconst listPrefix = directory === \"\" ? \"\" : `${directory}/`;\n\t\tconst { objects } = await store.list(listPrefix);\n\t\treturn objects\n\t\t\t.map((object) => object.key.slice(listPrefix.length))\n\t\t\t.filter((path) => path.length > 0)\n\t\t\t.sort();\n\t}\n\n\tfunction registerGitdir(gitdir: string, facts?: GitdirFacts): void {\n\t\tregisteredGitdirs.set(\n\t\t\tnormalizePath(gitdir),\n\t\t\tnew Set(facts?.absentFiles ?? []),\n\t\t);\n\t}\n\n\tfunction invalidate(pathPrefix: string): void {\n\t\tconst normalized = normalizePath(pathPrefix);\n\t\tfor (const dir of registeredGitdirs.keys()) {\n\t\t\tif (dir.startsWith(normalized)) registeredGitdirs.delete(dir);\n\t\t}\n\t\tfor (const scope of looseHints.keys()) {\n\t\t\tif (scope.startsWith(normalized)) looseHints.delete(scope);\n\t\t}\n\t\tconst maybe = store as ObjectStore & {\n\t\t\tinvalidate?: (prefix: string) => void;\n\t\t};\n\t\tmaybe.invalidate?.(toKey(normalized));\n\t}\n\n\treturn {\n\t\tpromises,\n\t\tlistFilesRecursively,\n\t\tdetectLooseObjects,\n\t\tprefetchPacks,\n\t\tinvalidate,\n\t\tregisterGitdir,\n\t};\n}\n","import { einval } from \"./errors.js\";\n\n/**\n * Normalize an absolute-or-relative filesystem path into a storage key\n * segment: no leading/trailing slashes, `.` segments dropped, `..` resolved.\n * A `..` that would escape the root throws EINVAL — paths handed to the fs\n * must never address keys outside the configured prefix.\n */\nexport function normalizePath(filepath: string): string {\n\tconst segments = filepath.split(\"/\");\n\tconst out: string[] = [];\n\tfor (const segment of segments) {\n\t\tif (segment === \"\" || segment === \".\") continue;\n\t\tif (segment === \"..\") {\n\t\t\tif (out.length === 0) throw einval(\"resolve\", filepath);\n\t\t\tout.pop();\n\t\t\tcontinue;\n\t\t}\n\t\tout.push(segment);\n\t}\n\treturn out.join(\"/\");\n}\n\n/** Join a configured key prefix with a normalized path. */\nexport function toKey(prefix: string, filepath: string): string {\n\tconst normalized = normalizePath(filepath);\n\tif (prefix === \"\") return normalized;\n\treturn normalized === \"\" ? prefix : `${prefix}/${normalized}`;\n}\n","import type { ObjectStore } from \"./types.js\";\n\n/** Options accepted by {@link createRetryStore}. */\nexport interface RetryOptions {\n\t/** Retries after the first attempt (total attempts = retries + 1). Default 3. */\n\tretries?: number;\n\t/** Backoff base delay in milliseconds, doubled each attempt. Default 100. */\n\tinitialDelayMs?: number;\n\t/** Upper bound for the backoff base delay. Default 5000. */\n\tmaxDelayMs?: number;\n\t/** Random jitter added to each delay, as a fraction of it. Default 0.3. */\n\tjitter?: number;\n\t/**\n\t * Decide whether an error is worth retrying. The store contract maps\n\t * \"not found\" to `null` rather than throwing, so any thrown error is a\n\t * genuine failure; the default retries network faults, throttling, and\n\t * HTTP 5xx responses.\n\t */\n\tisRetryable?: (error: unknown) => boolean;\n\t/**\n\t * Circuit breaker configuration, or `false` to disable. After `threshold`\n\t * consecutive failures the store fails fast for `resetMs`, then lets one\n\t * request probe the backend again. Defaults: 5 failures, 30 000 ms.\n\t */\n\tbreaker?: false | { threshold?: number; resetMs?: number };\n\t/** Called before each retry sleep; useful for logging/metrics. */\n\tonRetry?: (info: {\n\t\tkey: string;\n\t\top: string;\n\t\tattempt: number;\n\t\tdelayMs: number;\n\t}) => void;\n}\n\n/**\n * Thrown instead of calling the backend while the circuit breaker is open.\n * Carries `code: \"EUNAVAILABLE\"` so callers can map it to a 503.\n */\nexport class CircuitOpenError extends Error {\n\treadonly code = \"EUNAVAILABLE\";\n\n\tconstructor() {\n\t\tsuper(\"Circuit breaker is open, object store unavailable\");\n\t\tthis.name = \"CircuitOpenError\";\n\t}\n}\n\nconst RETRYABLE_NAMES = new Set([\n\t\"TimeoutError\",\n\t\"RequestTimeout\",\n\t\"RequestTimeoutException\",\n\t\"SlowDown\",\n\t\"ThrottlingException\",\n\t\"TooManyRequestsException\",\n]);\n\nconst RETRYABLE_CODES = new Set([\n\t\"ECONNRESET\",\n\t\"ECONNREFUSED\",\n\t\"EPIPE\",\n\t\"ETIMEDOUT\",\n\t\"ENOTFOUND\",\n\t\"EAI_AGAIN\",\n\t\"EPROTO\",\n]);\n\nfunction defaultIsRetryable(error: unknown): boolean {\n\tif (typeof error !== \"object\" || error === null) return false;\n\tconst err = error as {\n\t\tname?: string;\n\t\tcode?: string;\n\t\t$metadata?: { httpStatusCode?: number };\n\t};\n\tif (err.name !== undefined && RETRYABLE_NAMES.has(err.name)) return true;\n\tif (err.code !== undefined && RETRYABLE_CODES.has(err.code)) return true;\n\tconst status = err.$metadata?.httpStatusCode;\n\treturn status !== undefined && (status >= 500 || status === 429);\n}\n\nconst sleep = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms));\n\n/**\n * Wrap an {@link ObjectStore} with retries (exponential backoff + jitter) and\n * an optional per-instance circuit breaker.\n *\n * Place this decorator closest to the network store, underneath any cache:\n * the cache then never stores transient failures, and callers coalesced onto\n * one request share a single retried attempt.\n */\nexport function createRetryStore(\n\tstore: ObjectStore,\n\toptions: RetryOptions = {},\n): ObjectStore {\n\tconst retries = options.retries ?? 3;\n\tconst initialDelayMs = options.initialDelayMs ?? 100;\n\tconst maxDelayMs = options.maxDelayMs ?? 5000;\n\tconst jitter = options.jitter ?? 0.3;\n\tconst isRetryable = options.isRetryable ?? defaultIsRetryable;\n\tconst breaker =\n\t\toptions.breaker === false\n\t\t\t? null\n\t\t\t: {\n\t\t\t\t\tthreshold: options.breaker?.threshold ?? 5,\n\t\t\t\t\tresetMs: options.breaker?.resetMs ?? 30_000,\n\t\t\t\t};\n\n\tlet failures = 0;\n\tlet lastFailureAt = 0;\n\tlet state: \"closed\" | \"open\" | \"half-open\" = \"closed\";\n\tlet probing = false;\n\n\t/**\n\t * Consecutive transient failures open the circuit; any success closes it\n\t * and resets the count. Non-retryable errors (a 403, a malformed request)\n\t * say nothing about the backend's health and never count. Once the reset\n\t * window passes, exactly one request probes the backend (half-open);\n\t * everything else keeps failing fast until that probe settles.\n\t */\n\tasync function guarded<T>(fn: () => Promise<T>): Promise<T> {\n\t\tif (breaker === null) return fn();\n\t\tlet isProbe = false;\n\t\tif (state !== \"closed\") {\n\t\t\tif (\n\t\t\t\tprobing ||\n\t\t\t\t(state === \"open\" && Date.now() - lastFailureAt < breaker.resetMs)\n\t\t\t) {\n\t\t\t\tthrow new CircuitOpenError();\n\t\t\t}\n\t\t\tstate = \"half-open\";\n\t\t\tprobing = true;\n\t\t\tisProbe = true;\n\t\t}\n\t\ttry {\n\t\t\tconst result = await fn();\n\t\t\tfailures = 0;\n\t\t\tstate = \"closed\";\n\t\t\treturn result;\n\t\t} catch (error) {\n\t\t\tif (isRetryable(error)) {\n\t\t\t\tfailures++;\n\t\t\t\tlastFailureAt = Date.now();\n\t\t\t\tif (failures >= breaker.threshold || isProbe) state = \"open\";\n\t\t\t} else if (isProbe) {\n\t\t\t\t// The backend answered; it's up.\n\t\t\t\tfailures = 0;\n\t\t\t\tstate = \"closed\";\n\t\t\t}\n\t\t\tthrow error;\n\t\t} finally {\n\t\t\tif (isProbe) probing = false;\n\t\t}\n\t}\n\n\tasync function run<T>(op: string, key: string, fn: () => Promise<T>) {\n\t\tlet lastError: unknown;\n\t\tfor (let attempt = 0; attempt <= retries; attempt++) {\n\t\t\ttry {\n\t\t\t\treturn await guarded(fn);\n\t\t\t} catch (error) {\n\t\t\t\tlastError = error;\n\t\t\t\tif (error instanceof CircuitOpenError) throw error;\n\t\t\t\tif (!isRetryable(error) || attempt === retries) throw error;\n\t\t\t\tconst base = Math.min(initialDelayMs * 2 ** attempt, maxDelayMs);\n\t\t\t\tconst delayMs = Math.round(base + Math.random() * base * jitter);\n\t\t\t\toptions.onRetry?.({ key, op, attempt: attempt + 1, delayMs });\n\t\t\t\tawait sleep(delayMs);\n\t\t\t}\n\t\t}\n\t\tthrow lastError;\n\t}\n\n\treturn {\n\t\tget: (key) => run(\"get\", key, () => store.get(key)),\n\t\tput: (key, data) => run(\"put\", key, () => store.put(key, data)),\n\t\tdelete: (key) => run(\"delete\", key, () => store.delete(key)),\n\t\thead: (key) => run(\"head\", key, () => store.head(key)),\n\t\tlist: (prefix, listOptions) =>\n\t\t\trun(\"list\", prefix, () => store.list(prefix, listOptions)),\n\t};\n}\n","import type {\n\tListOptions,\n\tListResult,\n\tObjectStat,\n\tObjectStore,\n} from \"../types.js\";\n\n/**\n * In-memory {@link ObjectStore}. Useful for tests, examples, and ephemeral\n * repositories; also the reference implementation for the list/delimiter\n * semantics other stores must match.\n */\nexport class MemoryObjectStore implements ObjectStore {\n\tprivate readonly objects = new Map<string, Uint8Array>();\n\n\tasync get(key: string): Promise<Uint8Array | null> {\n\t\tconst data = this.objects.get(key);\n\t\treturn data ? data.slice() : null;\n\t}\n\n\tasync getRange(\n\t\tkey: string,\n\t\tstart: number,\n\t\tend: number,\n\t): Promise<Uint8Array | null> {\n\t\tconst data = this.objects.get(key);\n\t\treturn data ? data.slice(start, end + 1) : null;\n\t}\n\n\tasync put(key: string, data: Uint8Array): Promise<void> {\n\t\tthis.objects.set(key, data.slice());\n\t}\n\n\tasync delete(key: string): Promise<void> {\n\t\tthis.objects.delete(key);\n\t}\n\n\tasync head(key: string): Promise<ObjectStat | null> {\n\t\tconst data = this.objects.get(key);\n\t\treturn data ? { size: data.byteLength } : null;\n\t}\n\n\tasync list(prefix: string, options?: ListOptions): Promise<ListResult> {\n\t\tconst delimiter = options?.delimiter;\n\t\tconst limit = options?.limit ?? Number.POSITIVE_INFINITY;\n\t\tconst objects: ListResult[\"objects\"] = [];\n\t\tconst prefixes = new Set<string>();\n\n\t\tfor (const [key, data] of this.objects) {\n\t\t\tif (!key.startsWith(prefix)) continue;\n\t\t\tconst rest = key.slice(prefix.length);\n\t\t\tif (delimiter !== undefined) {\n\t\t\t\tconst idx = rest.indexOf(delimiter);\n\t\t\t\tif (idx !== -1) {\n\t\t\t\t\tprefixes.add(prefix + rest.slice(0, idx + delimiter.length));\n\t\t\t\t} else {\n\t\t\t\t\tobjects.push({ key, size: data.byteLength });\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tobjects.push({ key, size: data.byteLength });\n\t\t\t}\n\t\t\tif (objects.length + prefixes.size >= limit) break;\n\t\t}\n\n\t\treturn { objects, prefixes: [...prefixes] };\n\t}\n\n\t/** Number of stored objects (test convenience, not part of ObjectStore). */\n\tget size(): number {\n\t\treturn this.objects.size;\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,gBAAgB;AA8EzB,IAAM,OAAO,uBAAO,MAAM;AAa1B,SAAS,cAAc,OAA0B;AAChD,MAAI,OAAO,MAAM,OAAO,SAAS;AACjC,aAAW,KAAK,MAAM,OAAO,QAAS,SAAQ,EAAE,IAAI,SAAS;AAC7D,aAAW,KAAK,MAAM,OAAO,SAAU,SAAQ,EAAE;AACjD,SAAO;AACR;AAEA,SAAS,eAAe,QAAgC;AACvD,SAAO;AAAA,IACN,SAAS,OAAO,QAAQ,IAAI,CAAC,OAAO,EAAE,GAAG,EAAE,EAAE;AAAA,IAC7C,UAAU,CAAC,GAAG,OAAO,QAAQ;AAAA,EAC9B;AACD;AAaO,SAAS,kBACf,OACA,UAAwB,CAAC,GACL;AACpB,QAAM,WAAW,QAAQ,YAAY,KAAK,OAAO;AACjD,QAAM,gBAAgB,QAAQ,iBAAiB,KAAK,KAAK,WAAW,EAAE;AACtE,QAAM,MAAM,QAAQ,SAAS;AAC7B,QAAM,YAAY,QAAQ;AAC1B,QAAM,cAAc,QAAQ,eAAe;AAC3C,QAAM,aAAa,QAAQ,cAAc;AACzC,QAAM,QAAQ,MAAM,UAAU,KAAK,KAAK;AACxC,QAAM,WAAW,QAAQ,YAAY;AACrC,QAAM,OAAO,QAAQ,QAAQ;AAC7B,QAAM,QAAQ,CAAC,SAAsB,OAAO,KAAK,MAAM,IAAI;AAC3D,QAAM,QAAQ,QAAQ;AACtB,QAAM,SAAS,QAAQ;AAEvB,QAAM,QAAQ,IAAI,SAA6B;AAAA,IAC9C,SAAS;AAAA,IACT,iBAAiB,CAAC,UAAW,UAAU,OAAO,IAAI,MAAM,cAAc;AAAA,IACtE;AAAA,EACD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,cAAc,QAAW;AAC5B,cAAM,MAAM,KAAK,QAAQ,SAAS;AAClC,YAAI,QAAQ,IAAI;AACf,mBAAS,IAAI,SAAS,KAAK,MAAM,GAAG,MAAM,UAAU,MAAM,CAAC;AAAA,QAC5D,OAAO;AACN,kBAAQ,KAAK,EAAE,KAAK,MAAM,KAAK,WAAW,CAAC;AAAA,QAC5C;AAAA,MACD,OAAO;AACN,gBAAQ,KAAK,EAAE,KAAK,MAAM,KAAK,WAAW,CAAC;AAAA,MAC5C;AACA,UAAI,QAAQ,SAAS,SAAS,QAAQ,MAAO;AAAA,IAC9C;AAEA,WAAO,EAAE,SAAS,UAAU,CAAC,GAAG,QAAQ,EAAE;AAAA,EAC3C;AAAA;AAAA,EAGA,IAAI,OAAe;AAClB,WAAO,KAAK,QAAQ;AAAA,EACrB;AACD;","names":["LRUCache","toKey","LRUCache"]}
|
package/dist/ops.js
CHANGED
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
import {
|
|
2
|
+
getObjectSize,
|
|
2
3
|
parseLooseObjectPath
|
|
3
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-G636FB7W.js";
|
|
4
5
|
import {
|
|
5
6
|
assertBranchExists,
|
|
6
7
|
assertSafeBranchName,
|
|
7
8
|
createBranchFrom,
|
|
9
|
+
createSemaphore,
|
|
8
10
|
deleteBranchByName,
|
|
9
11
|
encodePack,
|
|
10
12
|
listBranches,
|
|
11
13
|
resolveLooseRefFast,
|
|
12
14
|
storePack
|
|
13
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-QH3HS7VI.js";
|
|
14
16
|
import {
|
|
15
17
|
GitInvalidRequestError,
|
|
16
18
|
GitObjectNotFoundError,
|
|
@@ -20,7 +22,7 @@ import {
|
|
|
20
22
|
isSafeTreePath,
|
|
21
23
|
qualifyBranchRef,
|
|
22
24
|
readBlobContent
|
|
23
|
-
} from "./chunk-
|
|
25
|
+
} from "./chunk-HO6OPXUS.js";
|
|
24
26
|
|
|
25
27
|
// src/ops/commit.ts
|
|
26
28
|
import git2 from "isomorphic-git";
|
|
@@ -493,6 +495,7 @@ async function getCommitHistory(repo, options, hooks) {
|
|
|
493
495
|
|
|
494
496
|
// src/ops/diff.ts
|
|
495
497
|
var MAX_DIFF_TEXT_BYTES = 1024 * 1024;
|
|
498
|
+
var MAX_CONCURRENT_READS = 16;
|
|
496
499
|
function countContentLines(content) {
|
|
497
500
|
if (content.length === 0) return 0;
|
|
498
501
|
const lines = content.split("\n");
|
|
@@ -526,10 +529,49 @@ function buildDiffFile(path, before, after) {
|
|
|
526
529
|
newSize: after?.bytes.length
|
|
527
530
|
};
|
|
528
531
|
}
|
|
532
|
+
async function readDiffEntry(entry) {
|
|
533
|
+
return entry ? {
|
|
534
|
+
type: await entry.type(),
|
|
535
|
+
oid: await entry.oid(),
|
|
536
|
+
mode: await entry.mode()
|
|
537
|
+
} : void 0;
|
|
538
|
+
}
|
|
539
|
+
function buildSubmoduleDiff(filepath, before, after) {
|
|
540
|
+
if (before?.type === after?.type && before?.oid === after?.oid)
|
|
541
|
+
return void 0;
|
|
542
|
+
const line = (entry) => entry ? `${entry.type === "commit" ? "Subproject commit" : entry.type === "tree" ? "Directory" : "File"} ${entry.oid}
|
|
543
|
+
` : "";
|
|
544
|
+
return {
|
|
545
|
+
path: filepath,
|
|
546
|
+
status: !before ? "added" : !after ? "deleted" : "modified",
|
|
547
|
+
kind: "submodule",
|
|
548
|
+
additions: 0,
|
|
549
|
+
deletions: 0,
|
|
550
|
+
oldEntry: before,
|
|
551
|
+
newEntry: after,
|
|
552
|
+
patch: createTwoFilesPatch(
|
|
553
|
+
before ? `a/${filepath}` : "/dev/null",
|
|
554
|
+
after ? `b/${filepath}` : "/dev/null",
|
|
555
|
+
line(before),
|
|
556
|
+
line(after),
|
|
557
|
+
"",
|
|
558
|
+
"",
|
|
559
|
+
{ context: 3 }
|
|
560
|
+
)
|
|
561
|
+
};
|
|
562
|
+
}
|
|
529
563
|
async function diffTrees(repo, oldTreeOid, newTreeOid) {
|
|
530
|
-
const
|
|
564
|
+
const reads = createSemaphore(MAX_CONCURRENT_READS);
|
|
565
|
+
const sideMeta = async (entry) => {
|
|
531
566
|
if (!entry || await entry.type() !== "blob") return null;
|
|
532
|
-
const
|
|
567
|
+
const oid = await entry.oid();
|
|
568
|
+
return { oid, size: await reads.run(() => getObjectSize(repo, oid)) };
|
|
569
|
+
};
|
|
570
|
+
const readContent = async (side) => {
|
|
571
|
+
if (!side) return null;
|
|
572
|
+
const { blob } = await reads.run(
|
|
573
|
+
() => git4.readBlob({ ...repo, oid: side.oid })
|
|
574
|
+
);
|
|
533
575
|
return readBlobContent(blob);
|
|
534
576
|
};
|
|
535
577
|
const trees = oldTreeOid ? [git4.TREE({ ref: oldTreeOid }), git4.TREE({ ref: newTreeOid })] : [git4.TREE({ ref: newTreeOid })];
|
|
@@ -542,6 +584,13 @@ async function diffTrees(repo, oldTreeOid, newTreeOid) {
|
|
|
542
584
|
oldEntry?.type(),
|
|
543
585
|
newEntry?.type()
|
|
544
586
|
]);
|
|
587
|
+
if (oldType === "commit" || newType === "commit") {
|
|
588
|
+
const [before2, after2] = await Promise.all([
|
|
589
|
+
readDiffEntry(oldEntry),
|
|
590
|
+
readDiffEntry(newEntry)
|
|
591
|
+
]);
|
|
592
|
+
return buildSubmoduleDiff(filepath, before2, after2);
|
|
593
|
+
}
|
|
545
594
|
if (oldType !== "blob" && newType !== "blob") return void 0;
|
|
546
595
|
if (oldEntry && newEntry && oldType === newType) {
|
|
547
596
|
const [oldOid, newOid] = await Promise.all([
|
|
@@ -550,9 +599,25 @@ async function diffTrees(repo, oldTreeOid, newTreeOid) {
|
|
|
550
599
|
]);
|
|
551
600
|
if (oldOid === newOid) return void 0;
|
|
552
601
|
}
|
|
602
|
+
const [oldSide, newSide] = await Promise.all([
|
|
603
|
+
sideMeta(oldEntry),
|
|
604
|
+
sideMeta(newEntry)
|
|
605
|
+
]);
|
|
606
|
+
if ((oldSide?.size ?? 0) > MAX_DIFF_TEXT_BYTES || (newSide?.size ?? 0) > MAX_DIFF_TEXT_BYTES) {
|
|
607
|
+
return {
|
|
608
|
+
path: filepath,
|
|
609
|
+
status: !oldSide ? "added" : !newSide ? "deleted" : "modified",
|
|
610
|
+
kind: "too-large",
|
|
611
|
+
additions: 0,
|
|
612
|
+
deletions: 0,
|
|
613
|
+
patch: "",
|
|
614
|
+
oldSize: oldSide?.size ?? void 0,
|
|
615
|
+
newSize: newSide?.size ?? void 0
|
|
616
|
+
};
|
|
617
|
+
}
|
|
553
618
|
const [before, after] = await Promise.all([
|
|
554
|
-
|
|
555
|
-
|
|
619
|
+
readContent(oldSide),
|
|
620
|
+
readContent(newSide)
|
|
556
621
|
]);
|
|
557
622
|
return before || after ? buildDiffFile(filepath, before, after) : void 0;
|
|
558
623
|
}
|
|
@@ -569,7 +634,11 @@ async function getCommitDiff(repo, commitSha) {
|
|
|
569
634
|
const { commit } = await getCommit(repo, commitSha);
|
|
570
635
|
const parent = commit.parent[0];
|
|
571
636
|
const parentTree = parent ? (await getCommit(repo, parent)).commit.tree : null;
|
|
572
|
-
return
|
|
637
|
+
return {
|
|
638
|
+
...await diffTrees(repo, parentTree, commit.tree),
|
|
639
|
+
oldRef: parent,
|
|
640
|
+
newRef: commitSha
|
|
641
|
+
};
|
|
573
642
|
}
|
|
574
643
|
async function getDiffBetweenRefs(repo, baseRef, compareRef) {
|
|
575
644
|
const [base, compare] = await Promise.all([
|
|
@@ -581,7 +650,11 @@ async function getDiffBetweenRefs(repo, baseRef, compareRef) {
|
|
|
581
650
|
oids: [base.oid, compare.oid]
|
|
582
651
|
});
|
|
583
652
|
const baseTree = mergeBase === void 0 ? null : mergeBase === base.oid ? base.commit.tree : (await getCommit(repo, mergeBase)).commit.tree;
|
|
584
|
-
return
|
|
653
|
+
return {
|
|
654
|
+
...await diffTrees(repo, baseTree, compare.commit.tree),
|
|
655
|
+
oldRef: mergeBase,
|
|
656
|
+
newRef: compare.oid
|
|
657
|
+
};
|
|
585
658
|
}
|
|
586
659
|
|
|
587
660
|
// src/ops/file-history.ts
|
|
@@ -611,7 +684,7 @@ async function getFileHistory(repo, options, hooks) {
|
|
|
611
684
|
const cachedOid = oidByCommitTree.get(commitTreeOid);
|
|
612
685
|
if (cachedOid !== void 0) return cachedOid;
|
|
613
686
|
const entry = await findTreeEntry(repo, commitTreeOid, options.filePath);
|
|
614
|
-
const oid = entry
|
|
687
|
+
const oid = entry && entry.type !== "tree" ? entry.oid : null;
|
|
615
688
|
oidByCommitTree.set(commitTreeOid, oid);
|
|
616
689
|
return oid;
|
|
617
690
|
}
|
|
@@ -806,6 +879,97 @@ async function fastForwardMerge(repo, sourceBranch, targetBranch) {
|
|
|
806
879
|
});
|
|
807
880
|
return { success: true, commitSha: sourceOid };
|
|
808
881
|
}
|
|
882
|
+
|
|
883
|
+
// src/ops/submodules.ts
|
|
884
|
+
function parseValue(raw) {
|
|
885
|
+
let value = "";
|
|
886
|
+
let spaces = "";
|
|
887
|
+
let quoted = false;
|
|
888
|
+
const escapes = {
|
|
889
|
+
n: "\n",
|
|
890
|
+
t: " ",
|
|
891
|
+
b: "\b",
|
|
892
|
+
"\\": "\\",
|
|
893
|
+
'"': '"'
|
|
894
|
+
};
|
|
895
|
+
for (let i = 0; i < raw.length; i++) {
|
|
896
|
+
const c = raw.charAt(i);
|
|
897
|
+
if (c === "\\") {
|
|
898
|
+
const escaped = escapes[raw.charAt(++i)];
|
|
899
|
+
if (escaped === void 0) return null;
|
|
900
|
+
value += spaces + escaped;
|
|
901
|
+
spaces = "";
|
|
902
|
+
} else if (c === '"') {
|
|
903
|
+
value += spaces;
|
|
904
|
+
spaces = "";
|
|
905
|
+
quoted = !quoted;
|
|
906
|
+
} else if (!quoted && (c === "#" || c === ";")) break;
|
|
907
|
+
else if (!quoted && /\s/.test(c)) {
|
|
908
|
+
if (value) spaces += c;
|
|
909
|
+
} else {
|
|
910
|
+
value += spaces + c;
|
|
911
|
+
spaces = "";
|
|
912
|
+
}
|
|
913
|
+
}
|
|
914
|
+
return quoted ? null : value;
|
|
915
|
+
}
|
|
916
|
+
function parseGitmodules(content) {
|
|
917
|
+
const sections = /* @__PURE__ */ new Map();
|
|
918
|
+
let current;
|
|
919
|
+
const lines = [];
|
|
920
|
+
let pending = "";
|
|
921
|
+
for (const line of content.replace(/\r\n/g, "\n").split("\n")) {
|
|
922
|
+
const slashes = /\\+$/.exec(line)?.[0].length ?? 0;
|
|
923
|
+
if (slashes % 2 === 1) pending += line.slice(0, -1);
|
|
924
|
+
else {
|
|
925
|
+
lines.push(pending + line);
|
|
926
|
+
pending = "";
|
|
927
|
+
}
|
|
928
|
+
}
|
|
929
|
+
for (const line of lines) {
|
|
930
|
+
const trimmed = line.trim();
|
|
931
|
+
if (!trimmed || /^[#;]/.test(trimmed)) continue;
|
|
932
|
+
if (trimmed.startsWith("[")) {
|
|
933
|
+
const match = /^\[submodule\s+"((?:[^"\\]|\\["\\])*)"\]\s*(?:[#;].*)?$/i.exec(
|
|
934
|
+
trimmed
|
|
935
|
+
);
|
|
936
|
+
current = void 0;
|
|
937
|
+
if (!match?.[1]) continue;
|
|
938
|
+
const name = match[1].replace(/\\(["\\])/g, "$1");
|
|
939
|
+
current = sections.get(name) ?? { name };
|
|
940
|
+
sections.set(name, current);
|
|
941
|
+
continue;
|
|
942
|
+
}
|
|
943
|
+
if (!current) continue;
|
|
944
|
+
const field = /^(path|url)\s*=\s*(.*)$/i.exec(trimmed);
|
|
945
|
+
if (!field?.[1] || field[2] === void 0) continue;
|
|
946
|
+
const key = field[1].toLowerCase();
|
|
947
|
+
const value = parseValue(field[2]);
|
|
948
|
+
if (value === null) delete current[key];
|
|
949
|
+
else current[key] = value;
|
|
950
|
+
}
|
|
951
|
+
const valid = [...sections.values()].filter(
|
|
952
|
+
(s) => !!s.name && !!s.path && !!s.url && ![...s.path + s.url].some(
|
|
953
|
+
(c) => c.charCodeAt(0) < 32 || c.charCodeAt(0) === 127
|
|
954
|
+
) && !s.path.startsWith("/") && !s.path.includes("\\") && s.path.split("/").every(
|
|
955
|
+
(p) => p !== "" && p !== "." && p !== ".." && p.toLowerCase() !== ".git"
|
|
956
|
+
)
|
|
957
|
+
);
|
|
958
|
+
const counts = /* @__PURE__ */ new Map();
|
|
959
|
+
for (const s of valid) counts.set(s.path, (counts.get(s.path) ?? 0) + 1);
|
|
960
|
+
return valid.filter((s) => counts.get(s.path) === 1);
|
|
961
|
+
}
|
|
962
|
+
async function getSubmodules(repo, ref, hooks) {
|
|
963
|
+
let bytes;
|
|
964
|
+
try {
|
|
965
|
+
bytes = await getFileContent(repo, ".gitmodules", ref, hooks);
|
|
966
|
+
} catch (error) {
|
|
967
|
+
if (error instanceof GitPathNotFoundError) return [];
|
|
968
|
+
throw error;
|
|
969
|
+
}
|
|
970
|
+
if (bytes.length > 1024 * 1024) return [];
|
|
971
|
+
return parseGitmodules(new TextDecoder().decode(bytes));
|
|
972
|
+
}
|
|
809
973
|
export {
|
|
810
974
|
BANNER_WALK_DEPTH,
|
|
811
975
|
HISTORY_WALK_DEPTH,
|
|
@@ -830,9 +994,11 @@ export {
|
|
|
830
994
|
getFileContent,
|
|
831
995
|
getFileHistory,
|
|
832
996
|
getLastCommitsForTree,
|
|
997
|
+
getSubmodules,
|
|
833
998
|
getTreeFromRef,
|
|
834
999
|
listBranches,
|
|
835
1000
|
listTreeEntries,
|
|
1001
|
+
parseGitmodules,
|
|
836
1002
|
resolveCommit,
|
|
837
1003
|
resolveLooseRefFast,
|
|
838
1004
|
resultKeyPrefixes,
|