Repository navigation
fix(init): match devkit sentinel ids exactly - #1729
Merged
Merged
Conversation
3 tasks
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
hook_block_rangelocated a hook's# >>> devkit:<id>/# <<< devkit:<id>sentinels with an awkindex()prefix match, so a sentinel whose id extends another id answered the shorter id's lookup: a consumer-bracketed# >>> devkit:shellcheck-composite-actionsblock was returned for a lookup ofshellcheck. Found in the #1725 review; nothing in the template trips it today, but it is exactly what the #1725 fallback anchor (which walks predecessors such asshellcheck) and the feature excisions would silently mis-target the day someone sentinel-wraps a hook whose id is a prefix extension of another.The sentinel branch now regex-matches only the marker's whole-line shape, extracts the token after
devkit:up to the first whitespace, and compares it to the requested id as a string — the id is never interpolated into a regex, so a metacharacter in a hook id cannot change what matches. The template's opening sentinels carry trailing prose (# >>> devkit:actionlint — excised when …), which is why the token stops at whitespace rather than requiring end-of-line.Same hazard, same fix, in the two feature excisions:
render_actionlint_optoutandrender_release_optoutused unanchoredgrep/sedranges on# >>> devkit:actionlint/# >>> devkit:release, so…:actionlint-extraor…:release-notespairs would have been deleted too. Both are now anchored at line start and require whitespace or end-of-line after the id (-Ealternation, again because of the trailing prose). The structural branch's sweep stops are left id-agnostic on purpose: any sentinel must stop the comment sweep.Type of Change
feat-- New featurefix-- Bug fixdocs-- Documentation onlychore-- Maintenance task (deps, config, etc.)refactor-- Code restructuring (no behavior change)test-- Adding or updating testsci-- CI/CD pipeline changesbuild-- Build system or dependency changesrevert-- Reverts a previous commitstyle-- Code style (formatting, whitespace)Modifiers
!) -- This change breaks backward compatibilityChanges Made
assets/init-workspace.shhook_block_range:sentinel(line, dir)awk function (whole-line marker shape, token extracted, string equality against"# " dir " devkit:" id); docstring updated — the prefix hazard is gone, the feature-gating reason for keeping ungrouped hooks un-sentinelled staysrender_actionlint_optout,render_release_optout:grep -qE '^[[:space:]]*# >>> devkit:<id>([[:space:]]|$)'guard and the matchingsed -i -Erangetests/test_scaffold_preserved_hooks.py_shell_function(name)harness lifting one function's verbatim text out of the script into abash -crun (the script is not sourceable)hook_block_range); the extending id still resolves to its own sentinel range; the anchor walk ignores a prefix-extended sentinel (upgrade-driven, pin 1.15.1 ⇒ actionlint lands aftershellcheck, not after the composite block); the actionlint excision takes only its own pair (decoyactionlint-extrapair survives under the opt-out); the release excision takes only its own pair (realrender_release_optoutagainst a fixturejustfile.ghwith a decoyrelease-notespair)Changelog Entry
No changelog needed — the issue says so; no template sentinel triggers the prefix match today, so consumer-visible behaviour is unchanged.
Testing
just test)Manual Testing Details
--force --no-prompts --mode bothwithDEVKIT_FEATURES_DISABLED=actionlinton a config carrying the template's real actionlint block plus a decoy# >>> devkit:actionlint-extrapair: only the real block removed (19 lines), decoy intact;DEVKIT_FEATURES_DISABLED=releasestill drops everydevkit:releasesentinel andprepare-release:recipe fromjustfile.ghuv run pytest tests/test_scaffold_preserved_hooks.py tests/test_flake_hooks.py -q→ 115 passedbats -j 4 --filter '1660|1651|preserved|hook|1717|1725|optout|opt-out|release' tests/bats/init-workspace.bats→ 66 ok; the one failure is the known environmental one (the [FEATURE] Ship actionlint to consumers: the workflow-lint hook plus a managed actionlint.yaml config #1660 opt-out test shells out to a barepython3without PyYAML in the plainnix developshell; green in CI)shellcheck -xclean;prek run --all-files→ 55 hooks passedChecklist
docs/templates/, then runjust docs)CHANGELOG.mdin the[Unreleased]section (and pasted the entry above)Additional Notes
The issue's suggested end-of-line anchor would have broken the live actionlint excision because the template's opening sentinel carries trailing prose; "followed by whitespace or end-of-line" is the reading that matches the template, and the tests pin it.
Refs: #1727