Conversation
Two small fixes that together make `precisa-worktree setup <branch> && precisa-worktree dev --detach` actually work end-to-end for OSS repos: 1. `dev` was invoking the service script as `pnpm --filter <x> dev -- --port <n>`. Under pnpm 9 + a plain `"dev": "vite"` script, the `--` separator is preserved in the spawned argv, so vite saw `vite -- --port 4333` and silently fell back to its default port (4321). Removing the `--` forwards the flags directly (`vite --port 4333`). 2. `setup` always ran `git worktree add -b <branch>`, which fatal-errors if the branch already exists locally or on origin (common when bringing up a worktree for a branch that was created in the main worktree and pushed to origin). Detect that case via `git show-ref` and fall back to `git worktree add <path> <branch>` to check out the existing branch.
Automated Review — Round 1SummaryThe PR introduces a new utility function for checking branch existence and modifies the logic for adding git worktrees. While the changes improve functionality, there are performance considerations and potential issues with error handling. Changes
🔍 Found 2 suggestions (see inline comments) Reviewed by OpenAI gpt-4o-mini (fallback) | 1,160 in / 184 out | $0.0003 — Round 1 of 2 |
github-actions Bot
pushed a commit
that referenced
this pull request
Apr 23, 2026
## [1.5.1](v1.5.0...v1.5.1) (2026-04-23) ### Bug Fixes * **worktree-cli:** forward dev flags to vite and reuse existing branches ([#23](#23)) ([0cab460](0cab460))
rlueder
added a commit
that referenced
this pull request
Apr 24, 2026
…hes (#23) Two small fixes that together make `precisa-worktree setup <branch> && precisa-worktree dev --detach` actually work end-to-end for OSS repos: 1. `dev` was invoking the service script as `pnpm --filter <x> dev -- --port <n>`. Under pnpm 9 + a plain `"dev": "vite"` script, the `--` separator is preserved in the spawned argv, so vite saw `vite -- --port 4333` and silently fell back to its default port (4321). Removing the `--` forwards the flags directly (`vite --port 4333`). 2. `setup` always ran `git worktree add -b <branch>`, which fatal-errors if the branch already exists locally or on origin (common when bringing up a worktree for a branch that was created in the main worktree and pushed to origin). Detect that case via `git show-ref` and fall back to `git worktree add <path> <branch>` to check out the existing branch.
rlueder
pushed a commit
that referenced
this pull request
Apr 24, 2026
## [1.5.1](v1.5.0...v1.5.1) (2026-04-23) ### Bug Fixes * **worktree-cli:** forward dev flags to vite and reuse existing branches ([#23](#23)) ([935df8a](935df8a))
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Two small fixes that together make the end-to-end worktree flow —
precisa-worktree setup <branch> && precisa-worktree dev --detach—actually work for the OSS sites (fhir-brasil, medbench-brasil,
datasus-brasil). Both issues surfaced while setting up dev servers to
visually verify the Header / OpenFooter migration.
1. `dev`: drop the `--` separator before script args
Invocation was:
```
pnpm --filter dev -- --port
```
Under pnpm 9 with a plain `"dev": "vite"` script, the `--` separator
is preserved in the spawned argv, so vite receives
`vite -- --port 4333` and silently ignores the port flag, falling back
to its default (4321). Removing the `--` forwards the flags directly
(`vite --port 4333`), which is what all existing service configs
(platform, OSS repos) expect.
Verified locally: `pnpm --filter @fhir-brasil/site dev --port 9998`
binds to 9998; `pnpm --filter @fhir-brasil/site dev -- --port 9998`
falls back to 4321.
2. `setup`: reuse an existing branch instead of erroring
`setup` always ran `git worktree add -b ... origin/main`,
which fails with `fatal: a branch named '' already exists`
whenever the branch was created previously (e.g. in the main worktree,
then pushed, then later promoted to a real feature worktree).
Now: detect the case via `git show-ref` against local +
`refs/remotes/origin/`, and fall back to
`git worktree add ` (without `-b`) to check out the
existing branch.
Test plan