Skip to content
Closed
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
6 changes: 6 additions & 0 deletions dist/cz/bin/cz
Original file line number Diff line number Diff line change
Expand Up @@ -692,6 +692,12 @@ cmd_lint() {
return 1
}

local rest="${message#*$'\n'}"
[[ "$rest" != "$message" && "${rest%%$'\n'*}" != "" ]] && {
_err "body MUST begin one blank line after the description"
return 1
}

if [[ "${BREAKING_FOOTER-unset}" == "1" ]]; then
breaking_footer=true
elif [[ "${BREAKING_FOOTER-unset}" == "" ]]; then
Expand Down
8 changes: 8 additions & 0 deletions scripts/cz/cmd_lint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,14 @@ cmd_lint() {
return 1
}

# Validate blank line after subject when body/footer present
# Spec: "body MUST begin one blank line after the description"
local rest="${message#*$'\n'}"
[[ "$rest" != "$message" && "${rest%%$'\n'*}" != "" ]] && {
_err "body MUST begin one blank line after the description"
return 1
}

# Determine breaking-footer mode
if [[ "${BREAKING_FOOTER-unset}" == "1" ]]; then
breaking_footer=true
Expand Down
50 changes: 50 additions & 0 deletions scripts/cz/main_spec.sh
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,56 @@ Describe 'cz'
End
End

#───────────────────────────────────────────────────────────
# Body blank line (spec: body MUST begin one blank line)
#───────────────────────────────────────────────────────────
Describe 'body blank line'
It 'accepts single-line message (no body)'
Data "docs: correct spelling of CHANGELOG"
When run script "$BIN" lint
The status should be success
End

It 'accepts message with blank line before body'
Data
#|fix: prevent racing of requests
#|
#|Introduce a request id and a reference to latest request. Dismiss
#|incoming responses other than from latest request.
End
When run script "$BIN" lint
The status should be success
End

It 'rejects body without blank line separator'
Data
#|fix: prevent racing of requests
#|Introduce a request id and a reference to latest request.
End
When run script "$BIN" lint
The status should be failure
The stderr should include "body MUST begin one blank line after the description"
End

It 'rejects footer without blank line separator'
Data
#|feat: allow provided config object to extend other configs
#|BREAKING CHANGE: `extends` key in config file is now used for extending other config files
End
When run script "$BIN" lint
The status should be failure
The stderr should include "body MUST begin one blank line after the description"
End

It 'accepts message with only a trailing newline'
Data
#|docs: correct spelling of CHANGELOG
End
When run script "$BIN" lint
The status should be success
End
End

#───────────────────────────────────────────────────────────
# Invalid conventional commits
#───────────────────────────────────────────────────────────
Expand Down