Skip to content

ZIR-000: Add shareable commit message normalizer hooks - #368

Closed
zeroecco wants to merge 1 commit into
mainfrom
feature/commit-normalize-iter3
Closed

zeroecco wants to merge 1 commit into
mainfrom
feature/commit-normalize-iter3

Conversation

@zeroecco

Copy link
Copy Markdown

Summary

  • Adds .githooks/commit-msg that rejects commits whose subject line does not match ZIR-NNN: <non-empty description> (Merge/Revert commits are exempt)
  • Adds .githooks/prepare-commit-msg that auto-prepends ZIR-000: when the prefix is absent; skips merge, squash, and template commit sources so pre-populated messages are never garbled
  • Adds scripts/setup-hooks.sh for one-command developer opt-in (git config core.hooksPath .githooks)
  • Adds .github/workflows/commit-lint.yml that enforces the same pattern as the local hook on every PR — ^ZIR-[0-9]+: .+ — so CI catches any misses
  • Adds CONTRIBUTING.md documenting the format and setup steps

Design decisions

  • Single hook system only (.githooks/ + core.hooksPath). No duplicate hooks/ directory or second setup script.
  • CI and local hook use identical regex so a commit cannot pass one and fail the other.
  • prepare-commit-msg skips the template COMMIT_SOURCE to avoid prepending ZIR-000: onto a ZIR-XXX: template placeholder.
  • No unused variables passed into awk.

Test plan

  • Run bash scripts/setup-hooks.sh in a clone; verify git config core.hooksPath returns .githooks
  • Attempt git commit -m "no prefix" — should be rejected by commit-msg hook
  • Attempt git commit -m "ZIR-123: valid" — should succeed
  • Attempt git commit -m "ZIR-123: " (empty description) — should be rejected
  • Verify Merge branch foo is accepted
  • Open a PR with a non-conforming commit and confirm the CI workflow fails

Nightshift-Task: commit-normalize
Nightshift-Ref: https://github.com/marcus/nightshift

- .githooks/commit-msg: rejects commits missing ZIR-NNN: <description>
- .githooks/prepare-commit-msg: auto-prepends ZIR-000: when prefix absent,
  skips merge/squash/template sources to avoid garbling pre-populated messages
- scripts/setup-hooks.sh: one-command setup via git config core.hooksPath
- .github/workflows/commit-lint.yml: CI enforcement with identical pattern
- CONTRIBUTING.md: documents format and setup steps

Nightshift-Task: commit-normalize
Nightshift-Ref: https://github.com/marcus/nightshift
@flaub flaub closed this Oct 23, 2026
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.

2 participants