Skip to content

Add mise setup-worktree task for one-command worktree setup#6983

Merged
facumenzella merged 2 commits into
mainfrom
facu/tuist-worktree-setup-task
Jun 15, 2026
Merged

Add mise setup-worktree task for one-command worktree setup#6983
facumenzella merged 2 commits into
mainfrom
facu/tuist-worktree-setup-task

Conversation

@facumenzella

@facumenzella facumenzella commented Jun 12, 2026

Copy link
Copy Markdown
Member

Checklist

  • If applicable, unit tests
  • If applicable, create follow-up issues for purchases-android and hybrids

Motivation

Setting up a fresh git worktree meant hand-copying Local.xcconfig and re-running tuist install every time. This adds a small mise task to do that boilerplate.

Description

mise run setup-worktree symlinks Local.xcconfig from the primary checkout (so the API key is shared, not re-entered per worktree) and runs tuist install. You still tuist generate <Target> yourself.

Also wires up the install task the postinstall hook already pointed at but that never existed, so the hook stops erroring. CI uses mise shims only and never runs mise install, so nothing changes there.

Heads up: Local.xcconfig is now a symlink, so it's shared across worktrees. Per-worktree key/bundle-ID overrides need a real file in that worktree first (noted in the docs).

AI session context

AI Context

Metadata

Goal

Make Tuist + git-worktree devx smoother: a small task that handles the per-worktree boilerplate of a fresh checkout.

Initial Prompt

"How do Tuist handle worktrees? Is there something we can change to make devx smoother?" The actionable task that followed: implement option 3 from the investigation, a mise worktree-setup task.

Important Follow-up Prompts

  • Chose option 3 (mise setup task) over the API-key-env and symlink-only options.
  • Decided to fix the dangling postinstall hook by adding the missing install task.
  • Accepted documented manual verification as the testing bar (declined script-extraction + hermetic test for now).
  • Trimmed scope: the task does link + install only; tuist generate (and the earlier --no-open / arg-forwarding) was dropped as too much.

Agent Contribution

  • Investigated Tuist's worktree behavior: confirmed the ~/.cache/tuist global cache is content-addressed (shared across worktrees), while Local.xcconfig / generated workspace / Derived are per-worktree.
  • Found the postinstall = "mise run install" hook referenced a non-existent install task (silent error).
  • Added [tasks.install] and [tasks.setup-worktree] to mise.toml; documented in Contributing/DEVELOPMENT.md.

Human Decisions

  • Picked the mise-task approach and the fix-the-hook option.
  • Set the testing bar at documented manual verification.
  • Trimmed the task to link + install (no generate, no arg-forwarding).

Key Implementation Decisions

  • Decision: resolve the primary checkout via git rev-parse --git-common-dir and symlink Local.xcconfig from it.
    • Rationale: robust from any worktree; keeps one shared API key without per-worktree copies.
    • Rejected: per-worktree TUIST_RC_API_KEY env (option 1) and symlink-only with no task (option 2).
  • Decision: task stops after tuist install; the developer runs tuist generate <Target> themselves.
    • Rationale: bundling generate (full-workspace, or arg-forwarded target selection) read as over-engineered.

Files / Symbols Touched

  • mise.toml
    • Why: add install + setup-worktree tasks.
    • Symbols: [tasks.install], [tasks.setup-worktree] (depends = ["install"])
    • Review relevance: bash body, primary-checkout resolution and link/SAMPLE-fallback/warn branches under set -euo pipefail.
  • Contributing/DEVELOPMENT.md
    • Why: document worktree setup, mise trust, shared-symlink caveat.
    • Symbols: "Working in a git worktree" section.

Dependencies / Config / Migrations

  • No new packages. Activates the previously-dead postinstall hook for local mise install runs only.

Validation

  • Commands run:
    • mise tasks ls: both tasks listed, setup-worktree depends on install.
    • symlink logic standalone: linked correctly, idempotent re-run is a no-op, git check-ignore confirms Local.xcconfig ignored.
    • mise run setup-worktree: ran tuist install, symlink step skipped (link present), exit 0.
    • grep -rniE "mise (install|activate|run)" .circleci/ .github/: CI uses shims only, never mise install.
  • Manual verification: as above.
  • CI: Not run yet (will run on PR).

Validation Gaps

  • No automated regression test for the symlink resolver (would require extracting it to a committed script + hermetic git-worktree test).

Review Focus

  • Is fixing the postinstall hook (so local mise install now runs tuist install) the desired behavior?
  • Symlink write-through: tuist generate for PaywallsTester writes the API key into Local.xcconfig; through the symlink that mutates the shared file. Caveat is documented, is that acceptable?

Risks / Reviewer Notes

  • Risk: shared Local.xcconfig symlink breaks per-worktree key/bundle-ID overrides.
    • Evidence: Projects/PaywallsTester/Project.swift writes the key into Local.xcconfig.
    • Mitigation: documented, replace the symlink with a real file in that worktree first.

Non-goals / Out of Scope

  • Running tuist generate from the task (and target arg-forwarding).
  • Option 1 (auto-create Local.xcconfig from TUIST_RC_API_KEY) and option 2 (symlink-only).
  • Wiring a shell test into CircleCI.

Omitted Context

  • Raw transcript, unrelated exploration, and tool logs were omitted.

Note

Low Risk
Developer tooling and docs only; no runtime or CI behavior change beyond local mise install now running tuist install.

Overview
Adds mise run setup-worktree so a new git worktree can reuse the primary checkout’s Local.xcconfig (symlink) and run tuist install without hand-copying config or re-resolving deps. Developers still run tuist generate <Target> themselves.

Also defines the missing install task (tuist install) that postinstall already referenced, so local mise install stops failing on a dead hook. Contributing/DEVELOPMENT.md documents mise trust, the one-command flow, and that a shared symlink means per-worktree API key / bundle ID overrides need a real Local.xcconfig in that worktree.

Reviewed by Cursor Bugbot for commit 258172d. Bugbot is set up for automated code reviews on this repo. Configure here.

@facumenzella facumenzella requested a review from ajpallares June 12, 2026 09:30
@facumenzella facumenzella force-pushed the facu/tuist-worktree-setup-task branch from e30fdbf to 6f181ea Compare June 12, 2026 09:32
@facumenzella facumenzella marked this pull request as ready for review June 12, 2026 09:33
@facumenzella facumenzella requested a review from a team as a code owner June 12, 2026 09:33

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 6f181ea. Configure here.

Comment thread mise.toml
Adds a `setup-worktree` mise task that links Local.xcconfig from the
primary checkout, resolves deps, and generates the Tuist workspace, so a
fresh git worktree is ready to build in one command. Also defines the
`install` task the existing `postinstall` hook already referenced (it was
a no-op until now since no such task existed).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@facumenzella facumenzella force-pushed the facu/tuist-worktree-setup-task branch from 6f181ea to 97b2464 Compare June 12, 2026 10:01

@ajpallares ajpallares 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.

Nice QoL improvement indeed! Thanks!

@facumenzella facumenzella enabled auto-merge (squash) June 15, 2026 09:22
@facumenzella facumenzella merged commit 5467051 into main Jun 15, 2026
18 of 20 checks passed
@facumenzella facumenzella deleted the facu/tuist-worktree-setup-task branch June 15, 2026 09:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants