Skip to content

feat(cz)!: align validation and errors to Conventional Commits spec#76

Merged
vabatta merged 9 commits intomainfrom
fix/cz-spec-alignment
Mar 9, 2026
Merged

feat(cz)!: align validation and errors to Conventional Commits spec#76
vabatta merged 9 commits intomainfrom
fix/cz-spec-alignment

Conversation

@vabatta
Copy link
Contributor

@vabatta vabatta commented Mar 8, 2026

Summary

Aligns cz validation rules, error messages, and output to the Conventional Commits v1.0.0 spec. Adds machine-readable error codes and the -b short flag.

Changes

New enforcement:

Error codes:

  • Centralized error code registry (error_codes.sh) with kebab-case codes like [type-enum], [scope-required], [body-leading-blank]
  • All _err calls use code lookups with printf formatting for machine-readable output
  • Tests assert on [error-code] only, not message text

CLI:

  • Added -b short flag for --{no-}breaking-footer

Refactor:

  • Moved _err/_hint helpers to shared helpers.sh
  • All commands (lint, create, hook, init, config) use _err/_hint consistently

Docs:

  • Spec compliance table in gitcommitizen(5) mapping spec rules to enforcement
  • Updated -b short flag in manpage, completions

Breaking Change

Error message strings changed. CI scripts or tooling that parse cz lint stderr for specific text should use the [error-code] brackets instead.

Test plan

… spec

- Accept BREAKING-CHANGE as synonym for BREAKING CHANGE (spec #16)
- BREAKING CHANGE must be uppercase — lowercase is rejected (spec #15)
- Error messages now quote spec language:
  - "commits MUST be prefixed with a type" (spec #1)
  - "description MUST immediately follow the colon and space" (spec #5)
  - "breaking changes MUST be indicated by a BREAKING CHANGE footer" (spec #13)
- Move _err/_hint helpers to shared helpers.sh
- All error output uses _err/_hint consistently across commands

BREAKING CHANGE: error message strings changed — tooling that parses
stderr output (e.g. CI scripts matching specific error text) may need
updating
@github-actions
Copy link
Contributor

github-actions bot commented Mar 8, 2026

📊 Coverage Report

Script Coverage Change
cz 99.75% → 99.52% -.23% ⬇️

vabatta added 6 commits March 9, 2026 00:48
- cmd_create uses "description MUST NOT be empty" (practical for interactive)
- Strict BREAKING CHANGE regex: space or hyphen only (no tab/newline)
- config.sh warning converted to _hint helper
- Added test for BREAKING-CHANGE with explicit --breaking-footer flag
Centralize all error messages in an associative array registry
(error_codes.sh) with commitlint-style codes like [type-enum],
[scope-required], [body-leading-blank]. All _err calls now use
code lookups with printf formatting, making errors parseable.
Remove redundant message text checks from stderr assertions,
keeping only the [error-code] bracket checks. Value-specific
checks (filenames, scope names) are preserved.
The Conventional Commits spec requires: "body MUST begin one blank
line after the description." Single-line messages (no body) are
unaffected. Closes #75.
@vabatta vabatta changed the title fix(cz)!: align lint to Conventional Commits spec fix(cz)!: align validation and errors to Conventional Commits spec Mar 9, 2026
@vabatta vabatta changed the title fix(cz)!: align validation and errors to Conventional Commits spec feat(cz)!: align validation and errors to Conventional Commits spec Mar 9, 2026
@vabatta vabatta merged commit dde2edc into main Mar 9, 2026
8 checks passed
@vabatta vabatta deleted the fix/cz-spec-alignment branch March 9, 2026 00:45
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