feat: chore doesn't need ref
If we detect a chore commit, we don't check for the correct ref/close footer. ref: N25B-241
This commit is contained in:
@@ -86,20 +86,24 @@ if ! [[ "$HEADER" =~ $HEADER_REGEX ]]; then
|
|||||||
error_exit "Invalid header format.\n\nHeader must be in the format: <type>: <short description>\nAllowed types: ${ALLOWED_TYPES[*]}\nExample: feat: add new user authentication feature"
|
error_exit "Invalid header format.\n\nHeader must be in the format: <type>: <short description>\nAllowed types: ${ALLOWED_TYPES[*]}\nExample: feat: add new user authentication feature"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# 3. Validate the footer (last line) of the commit message
|
# Only validate footer if commit type is not chore
|
||||||
FOOTER=$(tail -n 1 "$COMMIT_MSG_FILE")
|
TYPE=$(echo "$HEADER" | cut -d':' -f1)
|
||||||
|
if [ "$TYPE" != "chore" ]; then
|
||||||
|
# 3. Validate the footer (last line) of the commit message
|
||||||
|
FOOTER=$(tail -n 1 "$COMMIT_MSG_FILE")
|
||||||
|
|
||||||
# Regex breakdown:
|
# Regex breakdown:
|
||||||
# ^(ref|close) - Starts with 'ref' or 'close'
|
# ^(ref|close) - Starts with 'ref' or 'close'
|
||||||
# : - Followed by a literal colon
|
# : - Followed by a literal colon
|
||||||
# \s - Followed by a single space
|
# \s - Followed by a single space
|
||||||
# N25B- - Followed by the literal string 'N25B-'
|
# N25B- - Followed by the literal string 'N25B-'
|
||||||
# [0-9]+ - Followed by one or more digits
|
# [0-9]+ - Followed by one or more digits
|
||||||
# $ - End of the line
|
# $ - End of the line
|
||||||
FOOTER_REGEX="^(ref|close): N25B-[0-9]+$"
|
FOOTER_REGEX="^(ref|close): N25B-[0-9]+$"
|
||||||
|
|
||||||
if ! [[ "$FOOTER" =~ $FOOTER_REGEX ]]; then
|
if ! [[ "$FOOTER" =~ $FOOTER_REGEX ]]; then
|
||||||
error_exit "Invalid footer format.\n\nFooter must be in the format: [ref/close]: <issue identifier>\nExample: ref: N25B-123"
|
error_exit "Invalid footer format.\n\nFooter must be in the format: [ref/close]: <issue identifier>\nExample: ref: N25B-123"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# 4. If the message has more than 2 lines, validate the separator
|
# 4. If the message has more than 2 lines, validate the separator
|
||||||
|
|||||||
Reference in New Issue
Block a user