Skip to content

fix(workspace): keep shared core.hooksPath intact across worktree-start - #1464

Merged
c-vigo merged 2 commits into
release/1.8.0from
bugfix/1463-worktree-hookspath-scope
Aug 12, 2026
Merged

c-vigo merged 2 commits into
release/1.8.0from
bugfix/1463-worktree-hookspath-scope

Conversation

@c-vigo

@c-vigo c-vigo commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Summary

just worktree-start ran git config --unset-all core.hooksPath from inside the new linked worktree. core.hooksPath is shared repo config, so the unset disarmed the main checkout's tracked .githooks shims repo-wide — the #1430 failure mode, self-inflicted by a primary devkit workflow.

Fix

Skip-when-set: a relative core.hooksPath resolves against each worktree's root, and .githooks is tracked (present in every worktree), so when the setting exists the tracked shims already cover all three hook stages in the new worktree. worktree-start now leaves the config untouched and skips prek install in that state. The old prek install path survives only as the fallback when no hooks path is configured at all (the unset line is gone — it was a no-op there anyway).

Rejected alternatives:

  • git config --worktree --unset-all: needs extensions.worktreeConfig repo-wide, and a worktree-scoped unset cannot mask a shared value — it would actually require a worktree-scoped SET plus the extension flip. More moving parts for no gain given the shims are already present.
  • Restore-after-install / restore-on-stop: still mutates shared state, leaving a disarm window (or a disarmed main checkout for the worktree's whole lifetime).

Both copies fixed identically: justfile.worktree and the scaffolded assets/workspace/.devcontainer/justfile.worktree.

Tests

TDD: test(workspace) commit landed RED first. Two new bats tests in tests/bats/worktree.bats drive the real recipe (both copies) in a sandbox repo with a bare origin and stubbed tools:

bats tests/bats/worktree.bats tests/bats/githooks.bats → 14/14 ok; full prek run --all-files green.

Notes

  • The [BUG] just doctor reports git hooks inert inside linked worktrees, where they are live #1454 doctor comments in justfile / assets/workspace/justfile still describe the pre-fix behavior ("worktree-start unsets core.hooksPath on purpose"); the doctor logic itself remains correct for both pre-fix worktrees and the fallback path, so those comments were left alone (minimal diff) — cheap follow-up if wanted.
  • git config commit.template .gitmessage in the same recipe also writes shared config from the worktree, but idempotently (same value as main); out of scope here.

Closes #1463

@c-vigo
c-vigo merged commit 1dcd0ea into release/1.8.0 Aug 12, 2026
12 checks passed
@c-vigo
c-vigo deleted the bugfix/1463-worktree-hookspath-scope branch August 12, 2026 11:38
c-vigo added a commit that referenced this pull request Aug 12, 2026
…ck (#1467)

## Summary

`release.yml`'s **Rollback on Failure** built a commit whose tree was
reset to `pre_finalize_sha` — a run-start snapshot — whenever the run
failed and the branch tip had moved at all. Any commit merged to the
release branch while a run was in flight was silently destroyed on that
run's failure (#1459: the merged content of #1447 and #1448 wiped off
`release/1.8.0` twice, both times with `finalize` *skipped*).

## Fix

The rollback branch step now proves the branch holds only this run's own
writes before touching anything, and refuses loudly otherwise:

1. **No-op when `finalize` never ran** (`needs.finalize.result ==
'skipped'`/empty) — this alone prevents both incidents.
2. **No-op for candidates** — finalize is branch-neutral unless
`release_kind == final` (second independent shield; both incidents were
candidates).
3. Retained `CURRENT_SHA == PRE_SHA` no-op.
4. **Chain proof before any write**: `finalize` now exports the exact
commit SHA it pushed (commit-action's `commit-sha` output) plus the
post-sync tip. The tip must be exactly the finalize commit parented on
`PRE_SHA`, or the sync commit directly on top of it — and since this org
squash-merges PRs (single-parent, indistinguishable by parentage alone),
the sync-tip path additionally gates on the sync commit's fixed message
`chore: sync issues and PRs` (devkit also pins the author
`commit-action-bot[bot]`; live-verified against the real 1.7.0
finalize/sync pair on `main`). Anything else ⇒ `::error` + step failure,
branch untouched; the failure issue and job summary report the outcome.

Only when the proof passes does the existing tree-at-`PRE_SHA` revert
commit run — at that point it is exactly a revert of the run's own
commits.

The PR-body restore step (and its Release-App token mint) now also skip
when finalize was skipped — finalize is the only PR-body writer.

**All three copies fixed consistently**: devkit's `release.yml`,
scaffolded `release-core.yml` (new `finalize_commit_sha` /
`finalize_result` workflow_call outputs), and the scaffolded
orchestrator `release.yml` — whose old rollback was a `git reset --hard
$PRE_SHA` + force-push with zero guards, now replaced by the identical
guarded API revert. Scaffold copies gate on the sync message only (the
commit-bot name is per-consumer, the shipped `sync-issues.yml` message
is a constant); script bodies are byte-identical between copies.

No concurrency group (issue proposal 4) — deliberately out of scope.

## Tests

TDD: `test(ci)` commit landed RED first (18 failed / 5 passed — the 5
were retained behaviors). New `tests/test_release_rollback_guard.py`
executes the actual workflow scripts against stubbed `gh`/`retry`
simulating the Git Data API, parametrized over both copies: both
incident shapes no-op, foreign-tip and foreign-parent refuse, foreign
squash commit atop finalize refuses (the row that fails against the
unhardened script), genuine sync commit reverts. Existing #1378
rollback-identity test rewritten to pin the App-token API rollback.

Verification (direct exit codes): `pytest
tests/test_release_rollback_guard.py
tests/test_workflow_release_publish.py` → 43 passed; broad `pytest
tests/` (excl. image/integration/flake) → 524 passed; `actionlint
.github/workflows/release.yml` clean; rendered-tree actionlint bats 6/6
(covers the scaffold copies in all modes); full `prek run --all-files` →
exit 0.

Also included: `chore` merge of `release/1.8.0` (brings in the #1463 fix
from #1464; changelog union resolved manually, mirror byte-identical),
and stale "branch reset to pre-finalization state" wording updated in
`docs/RELEASE_CYCLE.md` / `DOWNSTREAM_RELEASE.md` and the failure-issue
texts.

## Notes

- Failed-job output propagation for `finalize_commit_sha` follows the
pattern the job already relied on for `pre_finalize_sha`.
- The dead `git_user_name`/`git_user_email` plumbing in
`release-core.yml` (now unused after dropping the git-CLI rollback) is
left in place — removal ripples across three workflows; separate-issue
material.
- The interim operating rule from the issue (don't merge into a release
branch mid-run) becomes a courtesy rather than a data-integrity
requirement, but remains good practice.

Closes #1462
c-vigo added a commit that referenced this pull request Aug 12, 2026
…ling (#1471)

## Summary

After #1463 (PR #1464), `just worktree-start` no longer unsets
`core.hooksPath` — a configured hooks path is left untouched (the
tracked `.githooks` shims cover the new worktree) and the prek install
into the shared `.git/hooks` survives only as the fallback when no hooks
path is set. The #1454 doctor comments in both `justfile` copies still
asserted the old behavior was "the INTENDED state ... on purpose", which
would actively mislead the next hook-state investigation (the #1430 →
#1454 → #1461 → #1463 chain shows how much debugging here leans on these
comments).

## Changes

Comment-only, zero behavior delta:

- `justfile` + `assets/workspace/justfile`: the doctor linked-worktree
comment now describes post-#1463 reality — the shared-hooks PASS branch
covers the no-hooksPath fallback plus worktrees created before #1463; a
post-fix worktree keeps the shared setting and hits the normal
`.githooks` PASS branch. The `--git-path` rationale and the copies'
one-phrase wording difference are preserved. (These are independent
copies — `scripts/manifest.toml` mirrors only
`justfile.gh`/`justfile.worktree` — so both needed the hand edit.)
- `tests/bats/doctor.bats`, `tests/bats/consumer-doctor.bats`,
`tests/test_flake_hooks.py`: the same stale claim repeated in test
comments, folded in per the scope note on the issue.

Doctor logic and echo strings untouched; no changelog entry (internal
docs). TDD skipped: comment-only, non-testable.

## Verification

`bats tests/bats/doctor.bats tests/bats/consumer-doctor.bats` → 26/26
ok; full `prek run --all-files` → exit 0; clean tree.

Closes #1469
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant