chore: normalize commit messages via conventional-commits hook#14
chore: normalize commit messages via conventional-commits hook#14
Conversation
Nightshift-Task: commit-normalize Nightshift-Ref: https://github.com/marcus/nightshift
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6d4782a6fa
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
git-hooks/commit-msg
Outdated
| COMMIT_MSG=$(head -1 "$COMMIT_MSG_FILE") | ||
|
|
||
| TYPES="feat|fix|docs|chore|refactor|test|style|perf|ci" | ||
| PATTERN="^(${TYPES})(\([a-z0-9]([a-z0-9-]*[a-z0-9])?\))?!?: [a-z].{1,}" |
There was a problem hiding this comment.
Reject commit subjects ending with a period
The hook documents a "no trailing period" rule, but the subject regex ^[...]: [a-z].{1,} still accepts messages like fix: add parser. because it never excludes a final .. That means commits the README and error text say should fail are currently allowed, so the new validation is weaker than advertised.
Useful? React with 👍 / 👎.
scripts/setup-hooks.sh
Outdated
|
|
||
| REPO_ROOT="$(cd "$(dirname "$0")/.." && pwd)" | ||
| HOOKS_SOURCE="$REPO_ROOT/git-hooks" | ||
| HOOKS_DEST="$REPO_ROOT/.git/hooks" |
There was a problem hiding this comment.
Resolve hook destination from Git config
The installer hardcodes .git/hooks as the destination, but Git uses core.hooksPath when it is configured (often globally). In that setup this script prints "Installed" even though Git will ignore those symlinks, so commit-message enforcement silently does not run for affected developers. Use Git’s resolved hooks path instead of assuming .git/hooks.
Useful? React with 👍 / 👎.
* Initial plan * fix: reject commit subjects ending with a trailing period Co-authored-by: tannn <831788+tannn@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: tannn <831788+tannn@users.noreply.github.com>
* Initial plan * fix: resolve hook destination from git config core.hooksPath Co-authored-by: tannn <831788+tannn@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: tannn <831788+tannn@users.noreply.github.com>
Summary
git-hooks/commit-msg— a shell hook that validates commit messages against the Conventional Commits specificationscripts/setup-hooks.sh— an idempotent installer that symlinksgit-hooks/*into.git/hooks/with correct permissionsREADME.mdwith a Development Setup section documenting the commit convention and setup commandWhat the hook validates
<type>(<scope>): <description>(types:feat|fix|docs|chore|refactor|test|style|perf|ci)Test plan
bash scripts/setup-hooks.shruns cleanly and reports hook installedfeat(ui): add dark mode toggle) exits 0Feat: Add dark mode) exits 1 with clear error outputgit log --oneline main...commit-normalizeshows exactly one commit (no unrelated commits)🤖 Generated with Claude Code
Automated by nightshift