chore: validate commit scope in commit-msg hook#385
Merged
Conversation
cog verify in cocogitto 6.x does not validate the scope component of a conventional commit header against the configured `scopes` list (cocogitto/cocogitto#516). Fixed upstream in v7.0.0 by cocogitto/cocogitto#541, but mmdflux can't move to v7 yet because of the open cocogitto/cocogitto#558 monorepo bump_order regression. Add an inline shell check to [git_hooks.commit-msg] that extracts the scope from the header (handling the optional breaking-change `!` marker) and rejects anything not in the cog.toml scopes list. Single-line `scopes = [...]` parsing via awk; multi-line arrays would need a real TOML parser. Unscoped commits (root crate, per the project convention) continue to pass through. This avoids the round-trip cost of pushing a commit with an unrecognized scope and only finding out in CI. The block is tagged with the upstream issue references so the next person knows to drop it once both upstream changes are shippable. Contributors re-running `just setup-hooks` from the main repo will pick up the new hook automatically.
c49eb31 to
dc8e17f
Compare
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
cog verifyin cocogitto 6.x does not validate the scope component of a conventional commit header against the configuredscopeslist (cocogitto/cocogitto#516). Fixed upstream in v7.0.0 by cocogitto/cocogitto#541, but mmdflux can't move to cog 7 yet because of the open cocogitto/cocogitto#558 monorepobump_orderregression.Add an inline shell check to
[git_hooks.commit-msg]that extracts the scope from the header (handling the optional breaking-change!marker) and rejects anything not in thecog.tomlscopes list. Single-linescopes = [...]parsing via awk; multi-line arrays would need a real TOML parser. Unscoped commits (root crate, per the project convention) continue to pass through.This avoids the round-trip cost of pushing a commit with an unrecognized scope and only finding out in CI. The block is tagged with the upstream issue references so the next person knows when it's safe to drop.
Test plan
Exercised the snippet against six representative commit headers from outside the worktree (no actual commit needed):
docs(mmds): ...(the original miss)feat(mmds-core): ...docs: ...(no scope, root crate)feat(wasm)!: ...(breaking change)feat(typo)!: ...(breaking change, bad scope)chore(version): ...cog check HEAD~1..HEADclean on this commit.just setup-hooksfrom the main repo (not from a worktree —cog install-hookchokes on worktree.gitfiles) pick up the new hook automatically.Cleanup
Drop the marked block when both cocogitto/cocogitto#558 lands upstream and mmdflux moves to cog >= 7.