ソースを参照

Add `pre-commit` hook for contributors

Making it easier for our contributors (and ourselves) to run the codesniffer
and avoid having to comment about coding standards in PRs.
Jad Bitar 11 年 前
コミット
b237f5f967
1 ファイル変更25 行追加0 行削除
  1. 25 0
      contrib/pre-commit

+ 25 - 0
contrib/pre-commit

@@ -0,0 +1,25 @@
+#!/bin/sh
+FILES=`git diff --cached --name-only --diff-filter=ACMR HEAD | grep \\\\.php`
+
+# Determine if a file list is passed
+if [ "$#" -eq 1 ]
+then
+    oIFS=$IFS
+    IFS='
+    '
+    SFILES="$1"
+    IFS=$oIFS
+fi
+SFILES=${SFILES:-$FILES}
+
+if [ "$FILES" != "" ]
+then
+    echo "Running PHPCS"
+    ./vendor/bin/phpcs --standard=vendor/cakephp/cakephp-codesniffer/CakePHP $SFILES
+    if [ $? != 0 ]
+    then
+        echo "PHPCS Errors found; commit aborted."
+        exit 1
+    fi
+fi
+exit $?