[Storage] Replace isomorphic-git submodule with local adapter - #3841
Conversation
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Foundation changes for the storage/git stack: introduces URL redaction utilities, moves off isomorphic-git private imports by vendoring required internals, and hardens git auth/sparse-checkout behavior (with tests).
Changes:
- Add URL redaction + Git repo URL heuristics to
@php-wasm/utilwith new test coverage - Introduce storage-owned
isomorphic-gitinternals and update storage git code to use them - Add/standardize Git authentication error handling and ensure diagnostics redact sensitive URLs
Reviewed changes
Copilot reviewed 12 out of 14 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/playground/storage/src/test/git-sparse-checkout.spec.ts | Adds a regression test ensuring auth errors redact credentials/tokens |
| packages/playground/storage/src/lib/isomorphic-git-internals.ts | Adds a storage-owned subset of git internals (pkt-line, pack index, tree/commit/tag parsing, in-memory FS) |
| packages/playground/storage/src/lib/git-sparse-checkout.ts | Switches to local internals + redacts sensitive URLs in thrown error messages |
| packages/playground/storage/src/lib/git-create-dotgit-directory.ts | Switches GitIndex import to local internals and minor formatting |
| packages/playground/storage/src/lib/git-authentication-error.ts | Introduces a dedicated auth error that redacts repo URLs |
| packages/playground/storage/package.json | Adds isomorphic-git + sha.js deps needed by the new internals |
| packages/php-wasm/util/src/test/redact-sensitive-url.spec.ts | Adds tests for URL/text redaction behavior |
| packages/php-wasm/util/src/test/is-git-repo-url.spec.ts | Adds tests for Git repo URL heuristic + compatibility alias |
| packages/php-wasm/util/src/lib/redact-sensitive-url.ts | Adds URL/text redaction + “contains sensitive data” helpers |
| packages/php-wasm/util/src/lib/is-git-repo-url.ts | Adds seemsLikeGitRepoUrl heuristic + deprecated alias |
| packages/php-wasm/util/src/lib/index.ts | Exports new util helpers from the package entrypoint |
| package.json | Adds @types/sha.js for TypeScript typing support |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
d4fccce to
ae19ca3
Compare
4f47ebe to
fd79786
Compare
36b14e2 to
66aee89
Compare
| optimizeDeps: { | ||
| include: [ | ||
| 'async-lock', | ||
| 'buffer', | ||
| 'clean-git-ref', | ||
| 'crc-32', | ||
| 'diff3', | ||
| 'ignore', | ||
| 'ini', | ||
| 'pako', | ||
| 'pify', | ||
| 'sha.js', | ||
| 'sha.js/sha1.js', | ||
| ], | ||
| exclude: ['isomorphic-git'], | ||
| }, | ||
| resolve: { | ||
| alias: [ | ||
| { | ||
| find: /^isomorphic-git$/, | ||
| replacement: isomorphicGitEsmEntry, | ||
| }, | ||
| ], | ||
| }, |
There was a problem hiding this comment.
I've run it on my own staging and tested:
- My WordPress boots fine from scratch,
- Blueprints still install fine to the current My WordPress
akirk
left a comment
There was a problem hiding this comment.
From the personal-wp perspective everything works fine!
| optimizeDeps: { | ||
| include: [ | ||
| 'async-lock', | ||
| 'buffer', | ||
| 'clean-git-ref', | ||
| 'crc-32', | ||
| 'diff3', | ||
| 'ignore', | ||
| 'ini', | ||
| 'pako', | ||
| 'pify', | ||
| 'sha.js', | ||
| 'sha.js/sha1.js', | ||
| ], | ||
| exclude: ['isomorphic-git'], | ||
| }, | ||
| resolve: { | ||
| alias: [ | ||
| { | ||
| find: /^isomorphic-git$/, | ||
| replacement: isomorphicGitEsmEntry, | ||
| }, | ||
| ], | ||
| }, |
There was a problem hiding this comment.
I've run it on my own staging and tested:
- My WordPress boots fine from scratch,
- Blueprints still install fine to the current My WordPress
…erver-restart Conflict resolutions: - blueprints-v2/worker-thread-v2.ts: trunk deduplicated mountResources into the shared ../mounts module. Adopted trunk's version and ported this branch's root-cause mount-error message (f65ea7c) into the shared mountResources so that improvement isn't lost. - run-cli.spec.ts imports: kept both Worker (worker-dispose test) and ChildProcess (trunk) imports. - run-cli.spec.ts getConstants: took trunk's --workers=1 but dropped the now-inert process.exit spy, since this branch removed process.exit. Also reconciled six trunk-added tests that asserted the old process.exit(1) behavior to this branch's process.exit-free model: five now expect the thrown validation error; the `start --mode` test expects a clean CLIExitResult (exit 1). Ran npm install for trunk's new isomorphic-git / sha.js deps (submodule replaced by a local adapter in WordPress#3841).
What it does
Replaces the checked-in
isomorphic-gitsubmodule with a local adapter in@wp-playground/storagefor the private Git internals Playground already uses.This does not remove
isomorphic-gitas an npm dependency. It removes the repository-level submodule checkout and the direct imports from privateisomorphic-git/src/...files.Git behavior is intended to stay the same: fetching refs, sparse checkout, pack parsing, authentication errors, and
.gitmaterialization should produce the same results. This PR also does not add URL redaction or change how remote URLs are persisted.Rationale
The previous setup depended on implementation files inside an
isomorphic-gitsubmodule. Those files are not part of the public package API, and the submodule added extra setup, source-package, and dependabot plumbing.Keeping the adapter in storage makes the private-code boundary explicit while continuing to use public
isomorphic-gitnpm APIs such asindexPackandreadObject.Implementation
Adds
packages/playground/storage/src/lib/isomorphic-git-internals.tswith the Git parsing/rendering pieces storage depends on:GitPktLine,parseUploadPackResponse,GitPackIndex,GitTree,GitCommit,GitAnnotatedTag, andGitIndex.Updates storage Git code to import those symbols from the local adapter instead of
isomorphic-git/src/..., then removes the old declaration shim for private imports.Removes submodule-only plumbing from
.gitmodules, theisomorphic-gitgitlink,tools/scripts/package-source.sh,.github/dependabot.yml, andAGENTS.md.Adds Vite aliases and dependency optimizer settings so remote, Personal WP, and client builds consistently use the ESM
isomorphic-gitnpm package entrypoint.The review pass also tightens the local adapter by making
MemoryFsrepresent symlinks explicitly, using anoffsetToOidmap for pack slice lookups, and replacing the compact string comparator with an explicit one.Testing instructions
npx nx test playground-storage --testFile=git-sparse-checkout.spec.ts npx nx lint php-wasm-util npx nx lint playground-storage npx nx build:bundle php-wasm-util npx nx build:bundle playground-storage bash -n tools/scripts/package-source.sh