Niedzielski has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/305759

Change subject: functionalize code #chore
......................................................................

functionalize code #chore

Change-Id: I8c05ba50a42a89fd15d516ce86114d92cc8bb61b
---
M dev-scripts/pre-commit
1 file changed, 56 insertions(+), 26 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MobileFrontend 
refs/changes/59/305759/1

diff --git a/dev-scripts/pre-commit b/dev-scripts/pre-commit
index 90d6a28..1b30486 100755
--- a/dev-scripts/pre-commit
+++ b/dev-scripts/pre-commit
@@ -14,35 +14,65 @@
 
 map() { IFS= read -rd $'\0' "$@"; }
 
-# check for trailing whitespace
-git diff --cached --check
+compress-png() {
+       git-staged-files \*.png|while map file; do
+               echo "Compressing $file"
+               optipng -q -o7 "$file" && advpng -z -4 "$file" && advdef -z -4 
"$file" | grep Output
+               git add "$file"
+       done
+}
 
-make jshint
-make jscs
+compress-svg() {
+       git-staged-files \*.svg|while map file; do
+               make nodecheck
+               echo "Compressing $file"
+               # If anyone can figure out how to get the pretty option to work 
from the config
+               # file, feel free to remove it here.
+               node_modules/.bin/svgo --config=.svgo.yml "$file" --pretty
+               git add "$file"
+       done
+}
 
-if git-is-staged \*.js; then
-       make qunit
-fi
+test-whitespace() { git diff --cached --check; }
 
-if git-is-staged \*.php; then
-       make phplint
-fi
+test-js() {
+       local err=0
 
-if git-is-staged 'includes/skins/*.php'; then
-       make validatehtml > $result
-fi
+       make jshint || err+=1
+       make jscs || err+=1
 
-git-staged-files \*.png|while map file; do
-       echo "Compressing $file"
-       optipng -q -o7 "$file" && advpng -z -4 "$file" && advdef -z -4 "$file" 
| grep Output
-       git add "$file"
-done
+       if git-is-staged \*.js; then
+               make qunit || err+=1
+       fi
 
-git-staged-files \*.svg|while map file; do
-       make nodecheck
-       echo "Compressing $file"
-       # If anyone can figure out how to get the pretty option to work from 
the config
-       # file, feel free to remove it here.
-       node_modules/.bin/svgo --config=.svgo.yml "$file" --pretty
-       git add "$file"
-done
\ No newline at end of file
+       return $err
+}
+
+test-php() {
+       local err=0
+       if git-is-staged \*.php; then
+               make phplint || err+=1
+       fi
+
+       # todo: where is result set?
+       if git-is-staged 'includes/skins/*.php'; then
+               make validatehtml > $result || err+=1
+       fi
+
+       return $err
+}
+
+main() {
+       local err=0
+
+       compress-png
+       compress-svg
+
+       test-whitespace || err+=1
+       test-js || err+=1
+       test-php || err+=1
+
+       return $err
+}
+
+main "$@"
\ No newline at end of file

-- 
To view, visit https://gerrit.wikimedia.org/r/305759
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I8c05ba50a42a89fd15d516ce86114d92cc8bb61b
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/MobileFrontend
Gerrit-Branch: master
Gerrit-Owner: Niedzielski <sniedziel...@wikimedia.org>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to