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

Make git commit-msg hook configurable. #454

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
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
11 changes: 4 additions & 7 deletions scripts/git-hooks/commit-msg
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,9 @@

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: $PREFIX-135: Added the new picture field to the article feature."
REGEX=$($ROOT_DIR/vendor/bin/drupal yaml:get:value $ROOT_DIR/project.yml git.commit_message.regex)
MESSAGE=$($ROOT_DIR/vendor/bin/drupal yaml:get:value $ROOT_DIR/project.yml git.commit_message.instructions)
if ! grep -iqE "$REGEX" "$1"; then
echo -e "$MESSAGE";
exit 1;
fi
10 changes: 10 additions & 0 deletions template/project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,16 @@ git:
# Defining git remotes allows builds deployed via CI.
- [email protected]:bolt8.git
# - [email protected]:radass4.git
commit_message:
regex: '^$BLT-[0-9]+(: )[^ ].{15,}\.'
instructions: |
Invalid commit message. Commit messages must:

* Contain the project prefix followed by a hyphen
* Contain a ticket number followed by a colon and a space
* Be at least 15 characters long and end with a period.

Valid example: BLT-135: Added the new picture field to the article feature.

drush:
# You can set custom project aliases in drush/site-aliases/aliases.drushrc.php.
Expand Down