aboutsummaryrefslogtreecommitdiffstats
path: root/git-tools/hooks
diff options
context:
space:
mode:
authorChris Smith <toonarmy@phpbb.com>2010-07-08 01:03:43 +0100
committerChris Smith <toonarmy@phpbb.com>2010-08-10 14:48:45 +0100
commit66e58234ecf05a4c9cbc401490c602694c920ed4 (patch)
tree8f1b375c2e35dd5a89628a7d184bc77c3ed99f38 /git-tools/hooks
parentbfa7b287344462bbd6f8a0f02810f7a6b225f65a (diff)
downloadforums-66e58234ecf05a4c9cbc401490c602694c920ed4.tar
forums-66e58234ecf05a4c9cbc401490c602694c920ed4.tar.gz
forums-66e58234ecf05a4c9cbc401490c602694c920ed4.tar.bz2
forums-66e58234ecf05a4c9cbc401490c602694c920ed4.tar.xz
forums-66e58234ecf05a4c9cbc401490c602694c920ed4.zip
[task/git-tools] Beginnings of a syntax checking hook.
Currently this hook checks line length is less than or equal to 80 characters. PHPBB3-9768
Diffstat (limited to 'git-tools/hooks')
-rwxr-xr-xgit-tools/hooks/commit-msg26
1 files changed, 26 insertions, 0 deletions
diff --git a/git-tools/hooks/commit-msg b/git-tools/hooks/commit-msg
new file mode 100755
index 0000000000..be1923ab6b
--- /dev/null
+++ b/git-tools/hooks/commit-msg
@@ -0,0 +1,26 @@
+#!/bin/sh
+#
+# A hook to check syntax of a phpBB3 commit message, per:
+# * <http://wiki.phpbb.com/display/DEV/Git>
+# * <http://area51.phpbb.com/phpBB/viewtopic.php?p=209919#p209919>
+#
+# This is a commit-msg hook.
+#
+# To install this you can either copy or symlink it to
+# $GIT_DIR/hooks, example:
+#
+# ln -s ../../git-tools/hooks/commit-msg \\
+# .git/hooks/commit-msg
+
+status=0;
+
+if [ "$(wc --max-line-length "$1" | cut -f1 -d" ")" -gt 80 ]
+then
+ echo "The following lines are greater than 80 characters long:\n";
+
+ grep -nE '.{81,}' "$1";
+
+ status=1;
+fi
+
+exit $status;