aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Fischer <bantu@phpbb.com>2014-02-02 17:01:50 +0100
committerAndreas Fischer <bantu@phpbb.com>2014-02-02 17:11:30 +0100
commit16e81d4d18ec98ed853acd834886b69349ca53c9 (patch)
treee9363e6b7d50b761cc72def566e72eff4daf889a /git-tools
parentMerge remote-tracking branch 'github-bantu/ticket/12147' into develop-olympus (diff)
downloadphpbb-16e81d4d18ec98ed853acd834886b69349ca53c9.tar.gz
phpbb-16e81d4d18ec98ed853acd834886b69349ca53c9.tar.bz2
phpbb-16e81d4d18ec98ed853acd834886b69349ca53c9.zip
[ticket/11509] Fail on Travis CI if commit messages are improperly formatted.
PHPBB3-11509
Diffstat (limited to 'git-tools')
-rwxr-xr-xgit-tools/commit-msg-hook-range.sh30
1 files changed, 30 insertions, 0 deletions
diff --git a/git-tools/commit-msg-hook-range.sh b/git-tools/commit-msg-hook-range.sh
new file mode 100755
index 0000000000..66628c1d17
--- /dev/null
+++ b/git-tools/commit-msg-hook-range.sh
@@ -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