From 16e81d4d18ec98ed853acd834886b69349ca53c9 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Sun, 2 Feb 2014 17:01:50 +0100 Subject: [ticket/11509] Fail on Travis CI if commit messages are improperly formatted. PHPBB3-11509 --- git-tools/commit-msg-hook-range.sh | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100755 git-tools/commit-msg-hook-range.sh (limited to 'git-tools') 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 -- cgit v1.2.1 From ccd30912d94660b285dfd2181edc72759007ac99 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Fri, 21 Feb 2014 00:48:18 +0100 Subject: [ticket/11509] Three dots means sym. difference, but we only want new commits. PHPBB3-11509 --- git-tools/commit-msg-hook-range.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'git-tools') diff --git a/git-tools/commit-msg-hook-range.sh b/git-tools/commit-msg-hook-range.sh index 66628c1d17..3d0f22ac53 100755 --- a/git-tools/commit-msg-hook-range.sh +++ b/git-tools/commit-msg-hook-range.sh @@ -9,7 +9,7 @@ set -e if [ "$#" -ne 1 ]; then - echo "Expected one argument (commit range, e.g. eef1b586...1666476b)." + echo "Expected one argument (commit range, e.g. phpbb/develop..ticket/12345)." exit fi -- cgit v1.2.1 From fe5858902ed412946858b3f3358c3ac7a9163b49 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Fri, 21 Feb 2014 00:52:01 +0100 Subject: [ticket/11509] Output which commit is being inspected. PHPBB3-11509 --- git-tools/commit-msg-hook-range.sh | 2 ++ 1 file changed, 2 insertions(+) (limited to 'git-tools') diff --git a/git-tools/commit-msg-hook-range.sh b/git-tools/commit-msg-hook-range.sh index 3d0f22ac53..a0d165b726 100755 --- a/git-tools/commit-msg-hook-range.sh +++ b/git-tools/commit-msg-hook-range.sh @@ -20,6 +20,8 @@ COMMIT_RANGE="$1" for COMMIT_HASH in $(git rev-list --no-merges "$COMMIT_RANGE") do + echo "Inspecting commit message of commit $COMMIT_HASH" + # 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. -- cgit v1.2.1 From 42e8c2e8cf17f2937527404ee403b0e1cc1b0b70 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Fri, 21 Feb 2014 01:44:41 +0100 Subject: [ticket/11509] Exit with the expected (non-zero) exit status on failure. PHPBB3-11509 --- git-tools/commit-msg-hook-range.sh | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) (limited to 'git-tools') diff --git a/git-tools/commit-msg-hook-range.sh b/git-tools/commit-msg-hook-range.sh index a0d165b726..2b408c3e79 100755 --- a/git-tools/commit-msg-hook-range.sh +++ b/git-tools/commit-msg-hook-range.sh @@ -5,7 +5,6 @@ # # Calls the git commit-msg hook on all non-merge commits in a given commit range. # -set -e if [ "$#" -ne 1 ]; then @@ -14,10 +13,12 @@ then fi DIR=$(dirname "$0") -COMMIT_MSG_HOOK_PATH="$DIR/hooks/commit-msg" - COMMIT_RANGE="$1" +COMMIT_MSG_HOOK_PATH="$DIR/hooks/commit-msg" +COMMIT_MSG_HOOK_FATAL=$(git config --bool phpbb.hooks.commit-msg.fatal 2> /dev/null) +git config phpbb.hooks.commit-msg.fatal true +EXIT_STATUS=0 for COMMIT_HASH in $(git rev-list --no-merges "$COMMIT_RANGE") do echo "Inspecting commit message of commit $COMMIT_HASH" @@ -27,6 +28,24 @@ do # 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" + + # Invoke hook on commit message file. "$COMMIT_MSG_HOOK_PATH" "$COMMIT_MESSAGE_PATH" + + # If any commit message hook complains with a non-zero exit status, we + # will send a non-zero exit status upstream. + if [ $? -ne 0 ] + then + EXIT_STATUS=1 + fi + rm "$COMMIT_MESSAGE_PATH" done + +# Restore phpbb.hooks.commit-msg.fatal config +if [ -n "$COMMIT_MSG_HOOK_FATAL" ] +then + git config phpbb.hooks.commit-msg.fatal "$COMMIT_MSG_HOOK_FATAL" +fi + +exit $EXIT_STATUS -- cgit v1.2.1 From 6db849cba5ab716af24d3d66b14104eb463c9dff Mon Sep 17 00:00:00 2001 From: Dhruv Date: Mon, 16 Jun 2014 03:05:10 +0530 Subject: [ticket/12720] Allow commit heading to begin with lowercase letters PHPBB3-12720 --- git-tools/hooks/commit-msg | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'git-tools') diff --git a/git-tools/hooks/commit-msg b/git-tools/hooks/commit-msg index b156d276df..136606252c 100755 --- a/git-tools/hooks/commit-msg +++ b/git-tools/hooks/commit-msg @@ -191,12 +191,12 @@ do err=$ERR_HEADER; echo "$line" | grep -Eq "^\[(ticket/[0-9]+|feature/$branch_regex|task/$branch_regex)\] .+$" result=$? - if ! echo "$line" | grep -Eq "^\[(ticket/[0-9]+|feature/$branch_regex|task/$branch_regex)\] [A-Z].+$" + if ! echo "$line" | grep -Eq "^\[(ticket/[0-9]+|feature/$branch_regex|task/$branch_regex)\] [a-zA-Z].+$" then # Don't be too strict. # Commits may be temporary, intended to be squashed later. # Just issue a warning here. - complain "$severity: heading should be a sentence beginning with a capital letter." 1>&2 + complain "$severity: heading should be a sentence beginning with a letter." 1>&2 complain "You entered:" 1>&2 complain "$line" 1>&2 fi -- cgit v1.2.1