Add a clean-up script for use as a pre-commit hook

Change-Id: I0e87cbd2d653f4125e2a3d40cda30a3464a7a287
This commit is contained in:
James D. Forrester 2014-03-14 13:44:21 -07:00 committed by Jforrester
parent 9e730bf528
commit f81ce29bda
2 changed files with 38 additions and 0 deletions

View file

@ -20,3 +20,18 @@ $wgEnableJavaScriptTest = true;
Then open `http://URL_OF_MEDIAWIKI/index.php/Special:JavaScriptTest/qunit`
(for example, <http://localhost/w/index.php/Special:JavaScriptTest/qunit>).
Node-based code linting tests can be run locally using npm run:
<pre lang="bash">
npm install && npm test
</pre>
## 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:
<pre lang="bash">
ln -s bin/pre-commit.sh ../.git/hooks/pre-commit
</pre>

23
bin/pre-commit.sh Executable file
View file

@ -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