Skip to content
This repository was archived by the owner on Mar 5, 2025. It is now read-only.

Commit 121d865

Browse files
committed
Resolves #249: Adding yaml parser to git-commit hook.
1 parent eca54ce commit 121d865

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

template/scripts/git-hooks/commit-msg

+6-2
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,16 @@
55
# You may adapt the message length check. Currently checking it's longer than
66
# 15 characters.
77

8-
regex="^${project.prefix}-[0-9]+(: )[^ ].{15,}\."
8+
9+
GIT_ROOT=$(git rev-parse --show-toplevel)
10+
PREFIX=$($GIT_ROOT/../../vendor/bin/drupal yaml:get:value $GIT_ROOT/project.yml project.prefix)
11+
12+
regex="^${PREFIX}-[0-9]+(: )[^ ].{15,}\."
913
if ! grep -iqE "$regex" "$1"; then
1014
echo "Invalid commit message. Commit messages must:"
1115
echo "* Contain the project prefix followed by a hyphen"
1216
echo "* Contain a ticket number followed by a colon and a space"
1317
echo "* Be at least 15 characters long and end with a period."
14-
echo "Valid example: ${project.prefix}-135: Added the new picture field to the article feature."
18+
echo "Valid example: $PREFIX-135: Added the new picture field to the article feature."
1519
exit 1;
1620
fi

0 commit comments

Comments
 (0)