Repository navigation
feat(workspace): exempt a named set of commit types from Refs - #1639
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
DEVKIT_REFS_POLICYdecides which commit types may omit theRefs:line, but its"some types exempt" case is hardcoded to the literal type name
chore. A consumerthat adds a custom type via
DEVKIT_COMMIT_TYPEScannot exempt that type withoutexempting every type — so the two knobs compose badly: you can add the type, but
not give it the Refs treatment the type was added for.
This adds
DEVKIT_REFS_OPTIONAL_TYPES, a comma-separated (whitespace-tolerant)FULL REPLACEMENT list of the types that may omit
Refs:, mirroring the patternDEVKIT_COMMIT_TYPESandDEVKIT_BRANCH_TYPESalready establish. The enum staysas sugar; the narrower key wins.
Absent or blank resolves to
chore— byte-identical to today's default render fordevkit and every existing consumer.
Type of Change
feat-- New featureModifiers
!) -- This change breaks backward compatibilityChanges Made
The value feeds three renderers in lockstep — a consumer cannot patch this
locally, because CI re-derives the list from the same key:
.pre-commit-config.yamlassets/init-workspace.sh— newRESOLVED_REFS_OPTIONAL_TYPES, resolved next toRESOLVED_COMMIT_TYPESso the subset guard has the approved list;render_refs_policyrenders itnix/hooks.nix(refsOptionalTypesFor,consumer) →mkProjectShell's newrefsOptionalTypesargument inflake.nix→ the.vig-osreader inassets/workspace/flake.nixvalidate-commit-rangeassets/workspace/.github/actions/resolve-toolchain/action.yml— therefs-optional-typesoutputPlus the manifest surface: the key ships bare in
assets/workspace/.vig-os, isread before the template overwrite and written back on upgrade (else an upgrade
silently resets a consumer's exempt set and their issue-less commit type starts
failing
commit-checks).Precedence.
DEVKIT_REFS_OPTIONAL_TYPESwins overDEVKIT_REFS_POLICY; thescaffold prints a notice when both are set.
DEVKIT_REFS_POLICY=requiredremainsthe way to exempt nothing at all (an empty
--refs-optional-typesreads as falsyto
validate-commit-msgand reverts to its own{chore}default, which is whyrequiredstill travels as thenonesentinel).Guards. Entries must be lowercase alphanumerics AND a subset of the resolved
DEVKIT_COMMIT_TYPES— exempting a type the validator would reject anyway is amanifest bug. The scaffold aborts loudly and
mkProjectShellfails eval; CI warnsrather than failing the job.
hooksModule.defaultCommitTypesis now exported sothe flake's subset assert validates against the same list the argv is built from,
rather than a fourth copy of the stock 11.
Two bugs found in self-review and fixed in
8779f34b, each with a regression testcommitted first (
59a8490e):.pre-commit-config.yamlis preserved across upgrades, never template-overwritten,so its current arg is whatever the previous render left. Skipping the
sedbecausethe resolved value happened to equal the
choredefault stranded a consumernarrowing its exempt set with the previous, wider arg locally while CI resolved
the narrow one — precisely the local/CI divergence this issue exists to prevent.
CI's fallback on an invalid value fell back to the
DEVKIT_REFS_POLICYmapping;under
DEVKIT_REFS_POLICY=optionalthat switched the Refs gate off for every typebecause the narrower key had a typo. It now clamps to
choreunless the policy isalready narrower (
none). This is the one place the#1431commit-types analogyinverts — there the stock list is a subset of any sane custom one, here it is not.
docs/COMMIT_MESSAGE_STANDARD.mdis shipped to consumers and said onlychoreisexempt; it now carries the same consumer-knob pointer the commit-types table has.
Changelog Entry
Testing
just test)Manual Testing Details
tests/test_flake_hooks.py— 75 passed. Adds arefsoptionaltypesconsumer shell(custom
commitTypes+refsPolicy = "required"+refsOptionalTypes), whichpins both the rendered arg and the precedence in one assertion, plus three
eval-time refusals (charset, empty list, non-subset) and the template-reader
forwarding probe.
tests/test_ci_runner.py— 69 passed. Theresolve-toolchainresolution table,the precedence over each of the three policy values, and the clamp: an invalid
list under
optionalmust resolve tochore, underrequiredtonone, with a::warning::asserted throughexec_resolve_toolchain.tests/bats/init-workspace.bats— the#1633and knob suites: default unchanged,named set rendered + written back, the narrowing re-render, the precedence notice,
and two new loud-refusal rows (bad charset, non-subset).
pytest(1064 passed) andprek run --all-files(green, no reformats).devtoo:test_image.py::test_manifest_filesandtest_integration.py::test_github_cli_authentication— both need a freshly builtlocal dev image; the former is stale relative to
devitself (8e7c4916changed.pymarkdown).Checklist
docs/templates/, then runjust docs)CHANGELOG.mdin the[Unreleased]section (and pasted the entry above)Additional Notes
Two things deliberately left out of scope:
DEVKIT_REFS_POLICY. The issue allows either; keeping it as sugarcosts one
casearm per renderer and breaks no consumer. It also remains the onlyway to say "exempt nothing", since an empty list means
choreto the validator.render_commit_typesandrender_branch_typesgate on "key absent", so clearingthe key leaves the previous render in the preserved
.pre-commit-config.yaml.This PR matches that behaviour rather than diverging from it; fixing it properly
means an unconditional
sedguarded against the flake-hooks store symlink, acrossall three renders — a separate issue, not a drive-by here.
Refs: #1633