Repository navigation
fix(workspace): render the branch guard from the workflow model both ways - #1643
Merged
Merged
Conversation
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.
Description
render_workflow_modelapplies thegitflow → trunkretarget one way — itearly-returns unless the resolved model is
trunk. For every managed file ittouches that is harmless: the template overwrite restores the gitflow shape on the
next upgrade and the render simply does not re-run.
.pre-commit-config.yamlispreserved, so the trunk edits stayed in it forever.
A consumer switching back to gitflow therefore lost the dev-branch guard silently:
no-commit-to-branchstopped blocking direct commits todev, on a repo whose.vig-ossaysgitflow. No error, no notice.Last instance of the class fixed in #1640.
Type of Change
fix-- Bug fixModifiers
!) -- This change breaks backward compatibilityChanges Made
I scoped this out of #1641 believing it spanned many files and needed its own
design. That premise was wrong, and measuring it first is what made the fix small:
every other target self-heals, so the entire stale surface is two lines of one file.
ci.yml,codeql.yml,sync-issues.yml,prepare-release.yml,promote-release.yml.github/renovate-default.json["dev"]).devcontainer/justfile.gh.claude/skills/branch-naming/SKILL.md.pre-commit-config.yamlSo the
.pre-commit-config.yamledits move out ofrender_workflow_modelinto anew
render_branch_guard_model, which runs for both models and renders the devclause from the resolved model instead of only subtracting it under trunk. It
goes through the
precommit_render_targetresolver added in #1640, keeping thesymlink and absent-file refusals in one place. Each direction's anchors stop
matching once applied, so a re-run is a no-op and a default gitflow scaffold stays
byte-identical to the template.
One trap worth recording, because it silently produced a no-op fix. GNU sed
4.10 treats a mid-pattern
$in a basic regular expression as an end anchor, nota literal. So the obvious insert pattern
matches nothing at all — and fails silently, leaving the file untouched. The
existing
(?!dev$)strip only works because its$)sits at the very end of thepattern. Both metacharacters are escaped in the insert pattern for that reason;
the replacement side needs no escaping, since sed gives
$/^no meaning there.The comment in the source records this so the next person does not rediscover it.
Flake-hooks consumers were never affected: their guard comes from
mkProjectShell,which reads
DEVKIT_WORKFLOWat eval time (#1224/#1434) and was already correct inboth directions. It was only the scaffolded YAML that was one-way.
Changelog Entry
Testing
just test)Manual Testing Details
Four new bats cases, committed first (
5c33a7ca) with the two behavioural onesred:
(?!dev$)clause and its comment (red)does — this is the assertion that caught the silent no-op sed (red)
(green before, pins the new code path)
that the refactor keeps it)
Full runs, all green:
bats tests/bats/init-workspace.bats— 270 passed, 0 failed. Deliberatelyincludes the Per-consumer workflow-model knob (gitflow default / trunk opt-in) #1205 workflow-switch suite, the Upgrade deploys template .pre-commit-config.yaml into direnv consumers, shadowing the flake-generated config #1255 flake-hooks fixtures, the
feat(workspace): scaffold-time Refs policy knob (DEVKIT_REFS_POLICY) for validate-commit-msg + validate-commit-range #1282/[FEATURE] feat(workspace): scaffold-time commit-types knob (DEVKIT_COMMIT_TYPES) for validate-commit-msg + validate-commit-range #1431/[FEATURE] feat(workspace): scaffold-time branch-types knob (DEVKIT_BRANCH_TYPES) for the branch guard + mkProjectShell branchTypes #1432/[FEATURE] Refs policy: exempt a named set of commit types, not just the literal
chore#1633/[BUG] Clearing a scaffold knob leaves the previous render in the preserved .pre-commit-config.yaml #1640 knob suites and the trunk-render composition tests.pytest(minus the two suites needing a freshly built local image) — 1070passed, 1 skipped.
tests/test_flake_checks.pycaught atyposviolation in asource comment on the first run; reworded rather than allowlisted.
prek run --all-files— green, no reformats.Checklist
docs/templates/, then runjust docs)CHANGELOG.mdin the[Unreleased]section (and pasted the entry above)Additional Notes
The contradiction guard still refuses a
--workflowflag that contradicts thepersisted
DEVKIT_WORKFLOW; this changes nothing there. The switch path this fixesis the guard's own documented step 3 — set
DEVKIT_WORKFLOWin.vig-oson adedicated branch and re-run the upgrade.
Refs: #1642