Skip to content

feat(local-dev): deploy from a sibling git worktree via up --worktree/--branch#6031

Open
Yicong-Huang wants to merge 2 commits into
apache:mainfrom
Yicong-Huang:feat/local-dev-worktree-deploy
Open

feat(local-dev): deploy from a sibling git worktree via up --worktree/--branch#6031
Yicong-Huang wants to merge 2 commits into
apache:mainfrom
Yicong-Huang:feat/local-dev-worktree-deploy

Conversation

@Yicong-Huang

Copy link
Copy Markdown
Contributor

What changes were proposed in this PR?

bin/local-dev.sh can now build and run the stack from a sibling git worktree while the orchestration tooling itself always runs from the canonical checkout.

The key split is SELF_ROOT (where local-dev.sh, tui.py, and the docker overlay live — the tooling) vs SOURCE_ROOT (the application tree that gets built/run, which REPO_ROOT now points at).

  • up / auto accept --worktree=PATH or --branch=NAME (resolved to the worktree that has the branch checked out). A plain up returns to this checkout.
  • The selection persists to $STATE_DIR/deploy-source, so status / down / logs / single-service rebuild / auto all act on the active deployment. up re-marks the deploy target (branch / sha / worktree) at startup, and status --json gains "worktree" and "source" fields.
  • Build stamps are namespaced per source tree (sha1 of the absolute path), so switching worktrees can't let a stamp from tree A suppress the required first build of tree B.
  • Infra docker compose / .env / overlay stay pinned to the canonical checkout (orchestration), while the app schema/DDL still comes from the deployed source.
  • The interactive TUI mirrors the CLI: u / a accept the same selectors, and the banner + SRC-dirty column re-point to the active tree live (the shell exports TEXERA_DEPLOY_SOURCE; the TUI re-reads the persisted pointer after a switch).
  • Invalid --branch / --worktree fail fast with a clear, actionable message before anything is built or started.

Any related issues, documentation, discussions?

Closes #6030. The --help text and the in-TUI help (h) document the new selectors.

How was this PR tested?

Extended both existing local-dev test suites (all green):

  • bin/local-dev/tests/test_local_dev_sh.sh — 25 checks (6 new): --help documents the selectors; status --json carries worktree/source; a stale pointer is dropped and falls back to self; a valid pointer to a throwaway worktree (created and cleaned up in-test) is honored and reports its branch; invalid --branch and --worktree fail fast with rc=1.
  • bin/local-dev/tests/test_local_dev_tui.py — 43 checks (5 new): _stamp_dir_for matches the shell's sha1(path)[:12] namespacing; _resolve_deploy_source returns self when the pointer is missing/stale/points at a non-checkout, and the worktree when valid.

Run:

bash bin/local-dev/tests/test_local_dev_sh.sh
python3 -m pytest bin/local-dev/tests/test_local_dev_tui.py -q

Also verified manually that status --json against a persisted worktree pointer reports that worktree's branch/sha/source, and that bash -n / py_compile pass.

Was this PR authored or co-authored using generative AI tooling?

Generated-by: Claude Opus 4.8 (Claude Code)

…/--branch

Split the orchestration tree (SELF_ROOT — where local-dev.sh lives, always
main's copy of the tooling: the script, tui.py, docker overlay) from the
application source tree (SOURCE_ROOT). `up`/`auto` now take --worktree=PATH or
--branch=NAME to build/run a sibling worktree without disturbing the main
checkout; a plain `up` returns to this checkout. The choice persists to
$STATE_DIR/deploy-source so status/down/logs/<svc>/auto all follow it, and
status --json gains "worktree"/"source" fields. Build stamps are namespaced
per source so switching worktrees can't skip a needed build. The TUI mirrors
all of this: u/a accept the selectors and re-point the banner live.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown
Contributor

Automated Reviewer Suggestions

Based on the git blame history of the changed files, we recommend the following reviewers:

  • No candidates found from git blame history.

@Yicong-Huang Yicong-Huang requested a review from Copilot June 30, 2026 05:03

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 wasn't able to review any files in this pull request.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@Yicong-Huang Yicong-Huang requested a review from bobbai00 June 30, 2026 05:05
The deploy source's branch + short-sha was computed inline in four spots
(status JSON, status banner, the up Deploy-target line, the TUI dashboard
banner). Fold the three pre-existing copies plus the one this feature added
into a single `_git_head` helper.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@Yicong-Huang Yicong-Huang requested a review from Copilot June 30, 2026 06:17

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 wasn't able to review any files in this pull request.

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.

Let local-dev.sh deploy from a sibling git worktree

2 participants