Cscott has uploaded a new change for review.
https://gerrit.wikimedia.org/r/174047
Change subject: Add .jsonlintignore feature to the json-lint.php helper script.
......................................................................
Add .jsonlintignore feature to the json-lint.php helper script.
This allows modules to selectively ignore certain json files using
the standard jslint jenkins test, which runs json-lint. This is needed
by Parsoid, which has symlinks to submodules which appear broken
when running json-lint w/o submodules checked out.
Change-Id: I40d4504cd2b681bce04e5949f0ea5547704ae651
---
M bin/json-lint.php
1 file changed, 22 insertions(+), 0 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/integration/jenkins
refs/changes/47/174047/1
diff --git a/bin/json-lint.php b/bin/json-lint.php
index 2eb1212..165132f 100755
--- a/bin/json-lint.php
+++ b/bin/json-lint.php
@@ -17,6 +17,7 @@
Usage: $argv[0] [path [path] [...]]]
EOF;
+ exit( 1 );
}
/**
@@ -60,6 +61,24 @@
} # end of json_last_error_msg()
}
+# read a .jsonlintignore file, if present.
+$jsonlintignore = array();
+if ( file_exists( '.jsonlintignore' ) ) {
+ $jsonlintignore = file_get_contents( '.jsonlintignore' );
+ # split on newlines, of any form
+ $jsonlintignore = preg_split( '/[\\r\\n]+/', $jsonlintignore );
+ # ignore comment lines, starting with a hash
+ $jsonlintignore = preg_grep( '/\\s*#/', $jsonlintignore,
PREG_GREP_INVERT );
+}
+function is_ignored( $filename ) {
+ global $jsonlintignore;
+ foreach ( $jsonlintignore as $pattern ) {
+ if ( fnmatch( $pattern, $filename->getBasename() ) ) {
+ return true;
+ }
+ }
+}
+
$exitCode = 0;
foreach ( $paths as $path ) {
# Find json files and normalizes them to an iterator of SplFileInfo
@@ -75,6 +94,9 @@
}
foreach ( $jsonFiles as $file ) {
+ if ( is_ignored( $file ) ) {
+ continue;
+ }
$result = lint_json_file( $file->getPathname() );
if ( !$result ) {
$exitCode = 1;
--
To view, visit https://gerrit.wikimedia.org/r/174047
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I40d4504cd2b681bce04e5949f0ea5547704ae651
Gerrit-PatchSet: 1
Gerrit-Project: integration/jenkins
Gerrit-Branch: master
Gerrit-Owner: Cscott <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits