diff --git a/src/lint/linter/ArcanistCSSLintLinter.php b/src/lint/linter/ArcanistCSSLintLinter.php index a69929cf..25b1afe0 100644 --- a/src/lint/linter/ArcanistCSSLintLinter.php +++ b/src/lint/linter/ArcanistCSSLintLinter.php @@ -34,6 +34,17 @@ final class ArcanistCSSLintLinter extends ArcanistExternalLinter { return $config->getConfigFromAnySource('lint.csslint.bin', 'csslint'); } + public function getVersion() { + list($stdout) = execx('%C --version', $this->getExecutableCommand()); + + $matches = array(); + if (preg_match('/^v(?P\d+\.\d+\.\d+)$/', $stdout, $matches)) { + return $matches['version']; + } else { + return false; + } + } + public function getInstallInstructions() { return pht('Install CSSLint using `npm install -g csslint`.'); } diff --git a/src/lint/linter/ArcanistExternalLinter.php b/src/lint/linter/ArcanistExternalLinter.php index 4a952359..a858a54e 100644 --- a/src/lint/linter/ArcanistExternalLinter.php +++ b/src/lint/linter/ArcanistExternalLinter.php @@ -369,6 +369,21 @@ abstract class ArcanistExternalLinter extends ArcanistFutureLinter { return array_merge($mandatory_flags, $flags); } + public function getCacheVersion() { + $version = $this->getVersion(); + + if ($version) { + return $version.'-'.json_encode($this->getCommandFlags()); + } else { + // Either we failed to parse the version number or the `getVersion` + // function hasn't been implemented. + return json_encode($this->getCommandFlags()); + } + } + + public function getVersion() { + return null; + } protected function buildFutures(array $paths) { $executable = $this->getExecutableCommand(); diff --git a/src/lint/linter/ArcanistFlake8Linter.php b/src/lint/linter/ArcanistFlake8Linter.php index 36ecbd70..3fc905c3 100644 --- a/src/lint/linter/ArcanistFlake8Linter.php +++ b/src/lint/linter/ArcanistFlake8Linter.php @@ -34,6 +34,17 @@ final class ArcanistFlake8Linter extends ArcanistExternalLinter { return 'flake8'; } + public function getVersion() { + list($stdout) = execx('%C --version', $this->getExecutableCommand()); + + $matches = array(); + if (preg_match('/^(?P\d+\.\d+\.\d+)\b/', $stdout, $matches)) { + return $matches['version']; + } else { + return false; + } + } + public function getInstallInstructions() { return pht('Install flake8 using `easy_install flake8`.'); } diff --git a/src/lint/linter/ArcanistJSHintLinter.php b/src/lint/linter/ArcanistJSHintLinter.php index ffd444f4..52cb0146 100644 --- a/src/lint/linter/ArcanistJSHintLinter.php +++ b/src/lint/linter/ArcanistJSHintLinter.php @@ -35,18 +35,16 @@ final class ArcanistJSHintLinter extends ArcanistExternalLinter { } } - public function getCacheVersion() { + public function getVersion() { list($stdout) = execx('%C --version', $this->getExecutableCommand()); - // Extract version number from standard output. $matches = array(); - if (preg_match('/^jshint v(\d+\.\d+\.\d+)$/', $stdout, $matches)) { - $version = $matches[1]; + $regex = '/^jshint v(?P\d+\.\d+\.\d+)$/'; + if (preg_match($regex, $stdout, $matches)) { + return $matches['version']; } else { - $version = md5($stdout); + return false; } - - return $version . '-' . md5(json_encode($this->getCommandFlags())); } public function getInstallInstructions() { diff --git a/src/lint/linter/ArcanistPEP8Linter.php b/src/lint/linter/ArcanistPEP8Linter.php index 1058c8f1..688966d4 100644 --- a/src/lint/linter/ArcanistPEP8Linter.php +++ b/src/lint/linter/ArcanistPEP8Linter.php @@ -15,11 +15,6 @@ final class ArcanistPEP8Linter extends ArcanistExternalLinter { return 'pep8'; } - public function getCacheVersion() { - list($stdout) = execx('%C --version', $this->getExecutableCommand()); - return $stdout.implode(' ', $this->getCommandFlags()); - } - public function getDefaultFlags() { // TODO: Warn that all of this is deprecated. $config = $this->getEngine()->getConfigurationManager(); @@ -55,6 +50,17 @@ final class ArcanistPEP8Linter extends ArcanistExternalLinter { return $arc_root.'/externals/pep8/pep8.py'; } + public function getVersion() { + list($stdout) = execx('%C --version', $this->getExecutableCommand()); + + $matches = array(); + if (preg_match('/^(?P\d+\.\d+\.\d+)$/', $stdout, $matches)) { + return $matches['version']; + } else { + return false; + } + } + public function getInstallInstructions() { return pht('Install PEP8 using `easy_install pep8`.'); } diff --git a/src/lint/linter/ArcanistPhpcsLinter.php b/src/lint/linter/ArcanistPhpcsLinter.php index a5c292b2..e1fa3d9d 100644 --- a/src/lint/linter/ArcanistPhpcsLinter.php +++ b/src/lint/linter/ArcanistPhpcsLinter.php @@ -58,6 +58,18 @@ final class ArcanistPhpcsLinter extends ArcanistExternalLinter { return $config->getConfigFromAnySource('lint.phpcs.bin', 'phpcs'); } + public function getVersion() { + list($stdout) = execx('%C --version', $this->getExecutableCommand()); + + $matches = array(); + $regex = '/^PHP_CodeSniffer version (?P\d+\.\d+\.\d+)\b/'; + if (preg_match($regex, $stdout, $matches)) { + return $matches['version']; + } else { + return false; + } + } + public function shouldExpectCommandErrors() { return true; } diff --git a/src/lint/linter/ArcanistRubyLinter.php b/src/lint/linter/ArcanistRubyLinter.php index 2921f5f4..15ba1b72 100644 --- a/src/lint/linter/ArcanistRubyLinter.php +++ b/src/lint/linter/ArcanistRubyLinter.php @@ -26,6 +26,18 @@ final class ArcanistRubyLinter extends ArcanistExternalLinter { return 'ruby'; } + public function getVersion() { + list($stdout) = execx('%C --version', $this->getExecutableCommand()); + + $matches = array(); + $regex = '/^ruby (?P\d+\.\d+\.\d+)p\d+/'; + if (preg_match($regex, $stdout, $matches)) { + return $matches['version']; + } else { + return false; + } + } + public function getInstallInstructions() { return pht('Install `ruby` from .'); }