Skip to content

feat(env): support standalone-repo worktrees in isolated envs#413

Open
jason10lee wants to merge 2 commits into
mainfrom
feat/env-standalone-worktrees
Open

feat(env): support standalone-repo worktrees in isolated envs#413
jason10lee wants to merge 2 commits into
mainfrom
feat/env-standalone-worktrees

Conversation

@jason10lee

Copy link
Copy Markdown
Contributor

All Submissions:

Changes proposed in this Pull Request:

Isolated environments can already mount worktrees of monorepo plugins/themes (n env create --worktree <plugin>:<branch>). This extends --worktree to standalone checkouts that live outside the monorepo at repos/{plugins,themes}/<name> — private or customer-specific plugins, licensed extensions, etc. — so they can be branch-isolated in an env the same way monorepo projects are.

A standalone checkout is discovered by path (no registration). Its worktree is created from the checkout's own git history at worktrees/standalone/<repo>/<branch> and mounted serving-only: unlike a monorepo worktree, a standalone repo is not a pnpm workspace member, so it gets no /newspack-monorepo/... workspace mount. n env destroy and n env list understand the new mount shape and clean it up / display it.

This is additive — monorepo (tier-1) and legacy worktree handling are unchanged.

  • bin/worktree.sh: n worktree add|remove <branch> --repo <name> for standalone checkouts; n worktree list enumerates standalone worktrees alongside workspace ones.
  • bin/worktree-mounts.sh (new): a small, host-testable helper that emits tier-aware compose volume lines (monorepo → serving + workspace-member; standalone → serving only). Unit-tested.
  • bin/env.sh: env create --worktree resolves standalone checkouts by path and mounts them tier-aware; the worktree-mount parser, env destroy, and env list gain standalone awareness.

How to test the changes in this Pull Request:

  1. Drop a real standalone plugin checkout at repos/plugins/<name> (clone, unzip, or git worktree add).
  2. n env create <env> --worktree <name>:<branch> --up — confirm the env comes up and the worktree is created at worktrees/standalone/<name>/<branch>.
  3. Visit the env URL and confirm the standalone plugin is served from the worktree (edit a file in the worktree, n build <name>, see the change).
  4. n env list — confirm the env shows the standalone worktree.
  5. n worktree list — confirm a [<name>] section lists the standalone worktree.
  6. n env destroy <env> — confirm the env, its worktree, and the branch are all removed.
  7. Regression: repeat 2–6 with a monorepo plugin (--worktree newspack-plugin:<branch>) and confirm tier-1 both-path mounting and cleanup still work.
  8. bash tests/worktree-mounts.test.sh — unit tests for the mount helper pass.

Other information:

  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your changes, as applicable?
  • Have you successfully run tests with your changes locally?

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings June 24, 2026 18:54
@jason10lee jason10lee self-assigned this Jun 24, 2026

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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@jason10lee jason10lee marked this pull request as ready for review June 24, 2026 20:37
@jason10lee jason10lee requested a review from a team as a code owner June 24, 2026 20:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants