Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ format on your commit messages:
Valid types: `feat`, `fix`, `docs`, `style`, `refactor`, `perf`, `test`, `build`,
`ci`, `chore`, `revert`. Add `!` after the type/scope for breaking changes.

Descriptions must contain at least one non-whitespace character.
Merge commits and fixup/squash commits are always allowed.

To disable this hook for a single commit:
Expand Down
2 changes: 1 addition & 1 deletion commit-msg
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ if echo "$msg" | grep -qE '^(fixup|squash)! '; then
exit 0
fi

pattern='^(feat|fix|docs|style|refactor|perf|test|build|ci|chore|revert)(\([a-zA-Z0-9_/-]+\))?!?: .+'
pattern='^(feat|fix|docs|style|refactor|perf|test|build|ci|chore|revert)(\([a-zA-Z0-9_/-]+\))?!?: .*[^[:space:]].*'

if ! echo "$msg" | grep -qE "$pattern"; then
echo "ERROR: Commit message does not follow Conventional Commits format."
Expand Down
6 changes: 6 additions & 0 deletions test/commit_msg_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ assert_rejected() {
}

run_hook 0 "feat: add checkout hook"
run_hook 0 "docs: clarify installation "
run_hook 0 $'fix: \tkeep a meaningful description'
run_hook 0 "fix(shell/hooks): preserve lfs args"
run_hook 0 "feat(api)!: change hook contract"
run_hook 0 "Merge pull request #6 from taigrr/cd/clear-conflicting-hook-config"
Expand All @@ -48,5 +50,9 @@ run_hook 0 "squash! test(shell): add regression coverage"
assert_rejected "update hook behavior"
assert_rejected "feature: add checkout hook"
assert_rejected "fix(shell):"
assert_rejected "fix: "
assert_rejected "fix(shell): "
assert_rejected $'feat(api)!: \t\t'
assert_rejected $'docs: \t \r'

echo "commit-msg regression tests passed"
Loading