Skip to content

[Storage] Replace isomorphic-git submodule with local adapter - #3841

Merged
adamziel merged 16 commits into
trunkfrom
stack/pr3725-05-storage-git-foundation
Jun 30, 2026
Merged

[Storage] Replace isomorphic-git submodule with local adapter#3841
adamziel merged 16 commits into
trunkfrom
stack/pr3725-05-storage-git-foundation

Conversation

@adamziel

@adamziel adamziel commented Jun 27, 2026

Copy link
Copy Markdown
Collaborator

What it does

Replaces the checked-in isomorphic-git submodule with a local adapter in @wp-playground/storage for the private Git internals Playground already uses.

This does not remove isomorphic-git as an npm dependency. It removes the repository-level submodule checkout and the direct imports from private isomorphic-git/src/... files.

Git behavior is intended to stay the same: fetching refs, sparse checkout, pack parsing, authentication errors, and .git materialization 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-git submodule. 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-git npm APIs such as indexPack and readObject.

Implementation

Adds packages/playground/storage/src/lib/isomorphic-git-internals.ts with the Git parsing/rendering pieces storage depends on: GitPktLine, parseUploadPackResponse, GitPackIndex, GitTree, GitCommit, GitAnnotatedTag, and GitIndex.

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, the isomorphic-git gitlink, tools/scripts/package-source.sh, .github/dependabot.yml, and AGENTS.md.

Adds Vite aliases and dependency optimizer settings so remote, Personal WP, and client builds consistently use the ESM isomorphic-git npm package entrypoint.

The review pass also tightens the local adapter by making MemoryFs represent symlinks explicitly, using an offsetToOid map 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

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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/util with new test coverage
  • Introduce storage-owned isomorphic-git internals 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.

Comment thread packages/playground/storage/src/lib/isomorphic-git-internals.ts Outdated
Comment thread packages/playground/storage/src/lib/isomorphic-git-internals.ts
Comment thread packages/playground/storage/src/lib/isomorphic-git-internals.ts
Comment thread packages/playground/storage/src/lib/isomorphic-git-internals.ts
Comment thread packages/playground/storage/src/lib/isomorphic-git-internals.ts
Comment thread packages/php-wasm/util/src/lib/redact-sensitive-url.ts Outdated
Comment thread packages/playground/storage/src/test/git-sparse-checkout.spec.ts Outdated
@adamziel
adamziel force-pushed the stack/pr3725-05-storage-git-foundation branch from d4fccce to ae19ca3 Compare June 27, 2026 22:37
@adamziel
adamziel changed the base branch from trunk to stack/pr3725-04-clear-vite-cache June 27, 2026 22:37
@adamziel
adamziel force-pushed the stack/pr3725-05-storage-git-foundation branch from 4f47ebe to fd79786 Compare June 28, 2026 21:39
@adamziel
adamziel force-pushed the stack/pr3725-04-clear-vite-cache branch from 36b14e2 to 66aee89 Compare June 28, 2026 21:39
Base automatically changed from stack/pr3725-04-clear-vite-cache to trunk June 28, 2026 21:57
@adamziel adamziel changed the title Build storage git foundation Jun 28, 2026
@adamziel adamziel changed the title [Storage] Build Git foundation for Blueprints v2 Jun 29, 2026
@adamziel adamziel changed the title [Storage] Stop importing private isomorphic-git internals Jun 29, 2026
@github-actions github-actions Bot added the [Type] Documentation Improvements or additions to documentation label Jun 29, 2026
@adamziel adamziel changed the title [Storage] Remove private isomorphic-git internals checkout Jun 29, 2026
@adamziel adamziel changed the title [Storage] Replace isomorphic-git submodule with package adapter Jun 29, 2026
Comment on lines +70 to +93
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,
},
],
},

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@akirk is this fine?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 akirk left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From the personal-wp perspective everything works fine!

Comment on lines +70 to +93
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,
},
],
},

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
@adamziel
adamziel merged commit 0c75d41 into trunk Jun 30, 2026
53 checks passed
@adamziel
adamziel deleted the stack/pr3725-05-storage-git-foundation branch June 30, 2026 11:27
gcsecsey added a commit to gcsecsey/wordpress-playground that referenced this pull request Jul 7, 2026
…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).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment