1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-04-13 20:32:11 +02:00

[ticket/11509] Fail on Travis CI if commit messages are improperly formatted.

PHPBB3-11509
This commit is contained in:
Andreas Fischer 2014-02-02 17:01:50 +01:00
parent ed43436c18
commit 16e81d4d18
2 changed files with 31 additions and 0 deletions

View File

@ -24,3 +24,4 @@ before_script:
script:
- sh -c "if [ '$TRAVIS_PHP_VERSION' = '5.2' ]; then phpunit --configuration travis/phpunit-$DB-travis.xml; else phpBB/vendor/bin/phpunit --configuration travis/phpunit-$DB-travis.xml; fi"
- sh -c "if [ '$TRAVIS_PULL_REQUEST' != 'false' ]; then git-tools/commit-msg-hook-range.sh $TRAVIS_COMMIT_RANGE; fi"

View File

@ -0,0 +1,30 @@
#!/bin/bash
#
# @copyright (c) 2014 phpBB Group
# @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
#
# Calls the git commit-msg hook on all non-merge commits in a given commit range.
#
set -e
if [ "$#" -ne 1 ];
then
echo "Expected one argument (commit range, e.g. eef1b586...1666476b)."
exit
fi
DIR=$(dirname "$0")
COMMIT_MSG_HOOK_PATH="$DIR/hooks/commit-msg"
COMMIT_RANGE="$1"
for COMMIT_HASH in $(git rev-list --no-merges "$COMMIT_RANGE")
do
# The git commit-msg hook takes a path to a file containing a commit
# message. So we have to extract the commit message into a file first,
# which then also needs to be deleted after our work is done.
COMMIT_MESSAGE_PATH="$DIR/commit_msg.$COMMIT_HASH"
git log -n 1 --pretty=format:%B "$COMMIT_HASH" > "$COMMIT_MESSAGE_PATH"
"$COMMIT_MSG_HOOK_PATH" "$COMMIT_MESSAGE_PATH"
rm "$COMMIT_MESSAGE_PATH"
done