aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndreas Fischer <bantu@phpbb.com>2012-04-20 14:55:03 +0200
committerAndreas Fischer <bantu@phpbb.com>2012-04-20 14:55:03 +0200
commit70cba4787104717d717037e1305081f9431d711c (patch)
tree3d738d3c432bcbcc744447d7a5d22710c0b7dfa2
parent4df8afd27e06c650ad44726d686e66b9bf610e7c (diff)
parent31fbc40a098bdd60979c89a4ea0a6bf55610cbdf (diff)
downloadforums-70cba4787104717d717037e1305081f9431d711c.tar
forums-70cba4787104717d717037e1305081f9431d711c.tar.gz
forums-70cba4787104717d717037e1305081f9431d711c.tar.bz2
forums-70cba4787104717d717037e1305081f9431d711c.tar.xz
forums-70cba4787104717d717037e1305081f9431d711c.zip
Merge branch 'develop-olympus' into develop
* develop-olympus: [ticket/10767] Clarify what happens at the end of the hook. [ticket/10767] Use warning/error language as appropriate. [ticket/10767] Default to non-fatal behavior. [ticket/10767] Revert unconditional unfatality in commit-msg hook.
-rwxr-xr-xgit-tools/hooks/commit-msg34
1 files changed, 30 insertions, 4 deletions
diff --git a/git-tools/hooks/commit-msg b/git-tools/hooks/commit-msg
index 52969670ca..b156d276df 100755
--- a/git-tools/hooks/commit-msg
+++ b/git-tools/hooks/commit-msg
@@ -12,6 +12,13 @@
# ln -s ../../git-tools/hooks/commit-msg \\
# .git/hooks/commit-msg
#
+# You can configure whether invalid commit messages abort commits:
+#
+# git config phpbb.hooks.commit-msg.fatal true (abort)
+# git config phpbb.hooks.commit-msg.fatal false (warn only, do not abort)
+#
+# The default is to warn only.
+#
# Warning/error messages use color by default if the output is a terminal
# ("output" here is normally standard error when you run git commit).
# To force or disable the use of color:
@@ -21,6 +28,15 @@
config_ns="phpbb.hooks.commit-msg";
+if [ "$(git config --bool $config_ns.fatal)" = "true" ]
+then
+ fatal=1;
+ severity=Error;
+else
+ fatal=0;
+ severity=Warning;
+fi
+
debug_level=$(git config --int $config_ns.debug || echo 0);
# Error codes
@@ -47,9 +63,19 @@ debug()
quit()
{
- # Now we always exit with success, since git will trash
- # entered commit message if commit-msg hook exits with a failure.
- exit 0
+ if [ $1 -eq 0 ] || [ $1 -eq $ERR_UNKNOWN ]
+ then
+ # success
+ exit 0;
+ elif [ $fatal -eq 0 ]
+ then
+ # problems found but fatal is false
+ complain 'Please run `git commit --amend` and fix the problems mentioned.' 1>&2
+ exit 0;
+ else
+ complain "Aborting commit." 1>&2
+ exit $1;
+ fi
}
use_color()
@@ -170,7 +196,7 @@ do
# Don't be too strict.
# Commits may be temporary, intended to be squashed later.
# Just issue a warning here.
- complain "Warning: heading should be a sentence beginning with a capital letter." 1>&2
+ complain "$severity: heading should be a sentence beginning with a capital letter." 1>&2
complain "You entered:" 1>&2
complain "$line" 1>&2
fi