From 8d3fa870c070fc505e1b20dfe840e910edc4630e Mon Sep 17 00:00:00 2001 From: Matthew Grasmick Date: Thu, 4 Aug 2016 15:15:37 -0400 Subject: [PATCH] Resolves #249: Adding yaml parser to git-commit hook. (#256) * Resolves #249: Adding yaml parser to git-commit hook. * Fixing root reference. --- template/scripts/git-hooks/commit-msg | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/template/scripts/git-hooks/commit-msg b/template/scripts/git-hooks/commit-msg index e37106282..2a280f93d 100755 --- a/template/scripts/git-hooks/commit-msg +++ b/template/scripts/git-hooks/commit-msg @@ -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