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

Resolves #249: Adding yaml parser to git-commit hook. #256

Merged
merged 2 commits into from
Aug 4, 2016
Merged
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
7 changes: 5 additions & 2 deletions template/scripts/git-hooks/commit-msg
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,15 @@
# You may adapt the message length check. Currently checking it's longer than
# 15 characters.

regex="^${project.prefix}-[0-9]+(: )[^ ].{15,}\."

ROOT_DIR="$(pwd)/"
PREFIX=$($ROOT_DIR/vendor/bin/drupal yaml:get:value $ROOT_DIR/project.yml project.prefix)
regex="^${PREFIX}-[0-9]+(: )[^ ].{15,}\."
if ! grep -iqE "$regex" "$1"; then
echo "Invalid commit message. Commit messages must:"
echo "* Contain the project prefix followed by a hyphen"
echo "* Contain a ticket number followed by a colon and a space"
echo "* Be at least 15 characters long and end with a period."
echo "Valid example: ${project.prefix}-135: Added the new picture field to the article feature."
echo "Valid example: $PREFIX-135: Added the new picture field to the article feature."
exit 1;
fi