chore: Makes the commit message hooks more portable (#1042)

Ditches awk and uses sed instead
This commit is contained in:
Tim Dévé 2020-12-01 19:35:43 +00:00 committed by GitHub
parent 0bd5fa4cb6
commit f89a3f130e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -3,8 +3,8 @@ set -euo noglob
VALID_TYPES="build|ci|chore|docs|feat|fix|perf|refactor|revert|style|test"
COMMIT_MESSAGE=$(cat "$1")
OUTPUT=$(echo "$COMMIT_MESSAGE" | awk "/^($VALID_TYPES)(\(.*\))?(!|)?: .*/");
if [ ${#OUTPUT} -gt 0 ]; then
OUTPUT=$(echo "$COMMIT_MESSAGE" | sed -n 1p | sed -E "s/^($VALID_TYPES)(\(.*\))?(\!|\\\!)?: .*//");
if [ ${#OUTPUT} -eq 0 ] && [ ${#COMMIT_MESSAGE} -ne 0 ]; then
exit 0;
else
echo "Commit message does not follow Conventional Commits."
@ -15,3 +15,4 @@ else
echo "For more information see https://www.conventionalcommits.org"
exit 1;
fi