Skip to content

Commit

Permalink
Resolves #249: Adding yaml parser to git-commit hook. (#256)
Browse files Browse the repository at this point in the history
* Resolves #249: Adding yaml parser to git-commit hook.

* Fixing root reference.
  • Loading branch information
grasmash authored Aug 4, 2016
1 parent c4b3d31 commit 8d3fa87
Showing 1 changed file with 5 additions and 2 deletions.
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

0 comments on commit 8d3fa87

Please sign in to comment.