diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 97dbf00ee5..e57316d1ed 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -20,3 +20,18 @@ $wgEnableJavaScriptTest = true; Then open `http://URL_OF_MEDIAWIKI/index.php/Special:JavaScriptTest/qunit` (for example, ). + +Node-based code linting tests can be run locally using npm – run: + +
+npm install && npm test
+
+ + +## Pre-commit hook + +A pre-commit git hook script exists which will help flag up any issues and avoid irritating code review steps for you and reviewers. Simply do: + +
+ln -s bin/pre-commit.sh ../.git/hooks/pre-commit
+
diff --git a/bin/pre-commit.sh b/bin/pre-commit.sh new file mode 100755 index 0000000000..393cb149c6 --- /dev/null +++ b/bin/pre-commit.sh @@ -0,0 +1,23 @@ +#!/usr/bin/env bash + +# If the VE core sub-module was touched +if git diff --quiet --cached lib/ve; then + + GITBRANCH=`git rev-parse --abbrev-ref HEAD`; + + # … and it doesn't look like + if [[ $GITBRANCH != "sync-repos" ]]; then + echo "VE core sub-module was touched but commit isn't from 'sync-repos'."; + exit 1; + fi + +fi + +# Stash any uncommited changes +git stash -q --keep-index + +npm install || git stash pop -q && exit 1 +npm test && git add -u .docs/* || git stash pop -q && exit 1 + +# Re-apply any uncommited changes +git stash pop -q