jenkins-bot has submitted this change and it was merged. Change subject: Hygiene: functionalize code in pre-commit hook ......................................................................
Hygiene: functionalize code in pre-commit hook Change-Id: I8c05ba50a42a89fd15d516ce86114d92cc8bb61b --- M dev-scripts/pre-commit 1 file changed, 56 insertions(+), 26 deletions(-) Approvals: Jdlrobson: Looks good to me, approved jenkins-bot: Verified 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: merged Gerrit-Change-Id: I8c05ba50a42a89fd15d516ce86114d92cc8bb61b Gerrit-PatchSet: 4 Gerrit-Project: mediawiki/extensions/MobileFrontend Gerrit-Branch: master Gerrit-Owner: Niedzielski <sniedziel...@wikimedia.org> Gerrit-Reviewer: Jdlrobson <jrob...@wikimedia.org> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits