From 87caf47366d9d01536525074837384f4a04b4192 Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Sun, 10 Mar 2013 07:10:55 -0400 Subject: [PATCH] tools/scripts/git - Add recommended hooks --- tools/scripts/git/commit-msg | 5 ++++ tools/scripts/git/post-checkout | 5 ++++ tools/scripts/git/post-merge | 5 ++++ tools/scripts/git/pre-commit | 37 ++++++++++++++++++++++++++++ tools/scripts/git/prepare-commit-msg | 5 ++++ 5 files changed, 57 insertions(+) create mode 100755 tools/scripts/git/commit-msg create mode 100755 tools/scripts/git/post-checkout create mode 100755 tools/scripts/git/post-merge create mode 100755 tools/scripts/git/pre-commit create mode 100755 tools/scripts/git/prepare-commit-msg diff --git a/tools/scripts/git/commit-msg b/tools/scripts/git/commit-msg new file mode 100755 index 0000000000..0017268479 --- /dev/null +++ b/tools/scripts/git/commit-msg @@ -0,0 +1,5 @@ +#!/bin/bash + +# Note: This shell script should be designed and tested for cross-platform use + +# Reserved for future use \ No newline at end of file diff --git a/tools/scripts/git/post-checkout b/tools/scripts/git/post-checkout new file mode 100755 index 0000000000..0017268479 --- /dev/null +++ b/tools/scripts/git/post-checkout @@ -0,0 +1,5 @@ +#!/bin/bash + +# Note: This shell script should be designed and tested for cross-platform use + +# Reserved for future use \ No newline at end of file diff --git a/tools/scripts/git/post-merge b/tools/scripts/git/post-merge new file mode 100755 index 0000000000..0017268479 --- /dev/null +++ b/tools/scripts/git/post-merge @@ -0,0 +1,5 @@ +#!/bin/bash + +# Note: This shell script should be designed and tested for cross-platform use + +# Reserved for future use \ No newline at end of file diff --git a/tools/scripts/git/pre-commit b/tools/scripts/git/pre-commit new file mode 100755 index 0000000000..7dcbd6d4e6 --- /dev/null +++ b/tools/scripts/git/pre-commit @@ -0,0 +1,37 @@ +#!/bin/bash + +# Note: This shell script should be designed and tested for cross-platform use + +# URL: https://github.com/totten/git-php-syntax-checker/ +# Author: Remigijus Jarmalavičius +# Author: Vytautas Povilaitis +# License: GPLv3 + +ROOT_DIR="$(pwd)/" +LIST=$(git diff-index --cached --name-only --diff-filter=ACMR HEAD) +ERRORS_BUFFER="" +for file in $LIST +do + EXTENSION=$(echo "$file" | grep -E ".php$|.module$|.inc$|.install$") + if [ "$EXTENSION" != "" ]; then + ERRORS=$(php -l $ROOT_DIR$file 2>&1 | grep "Parse error") + if [ "$ERRORS" != "" ]; then + if [ "$ERRORS_BUFFER" != "" ]; then + ERRORS_BUFFER="$ERRORS_BUFFER\n$ERRORS" + else + ERRORS_BUFFER="$ERRORS" + fi + echo "Syntax errors found in file: $file " + fi + fi +done +if [ "$ERRORS_BUFFER" != "" ]; then + echo + echo "These errors were found in try-to-commit files: " + echo -e $ERRORS_BUFFER + echo + echo "Can't commit, fix errors first." + exit 1 +else + echo "Commited successfully." +fi diff --git a/tools/scripts/git/prepare-commit-msg b/tools/scripts/git/prepare-commit-msg new file mode 100755 index 0000000000..0017268479 --- /dev/null +++ b/tools/scripts/git/prepare-commit-msg @@ -0,0 +1,5 @@ +#!/bin/bash + +# Note: This shell script should be designed and tested for cross-platform use + +# Reserved for future use \ No newline at end of file -- 2.25.1