diff --git a/src/lint/linter/ArcanistCSSLintLinter.php b/src/lint/linter/ArcanistCSSLintLinter.php --- a/src/lint/linter/ArcanistCSSLintLinter.php +++ b/src/lint/linter/ArcanistCSSLintLinter.php @@ -34,6 +34,17 @@ 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 --- a/src/lint/linter/ArcanistExternalLinter.php +++ b/src/lint/linter/ArcanistExternalLinter.php @@ -369,6 +369,21 @@ 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 --- a/src/lint/linter/ArcanistFlake8Linter.php +++ b/src/lint/linter/ArcanistFlake8Linter.php @@ -34,6 +34,17 @@ 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 --- a/src/lint/linter/ArcanistJSHintLinter.php +++ b/src/lint/linter/ArcanistJSHintLinter.php @@ -35,18 +35,16 @@ } } - 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 --- a/src/lint/linter/ArcanistPEP8Linter.php +++ b/src/lint/linter/ArcanistPEP8Linter.php @@ -15,11 +15,6 @@ 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 @@ 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 --- a/src/lint/linter/ArcanistPhpcsLinter.php +++ b/src/lint/linter/ArcanistPhpcsLinter.php @@ -58,6 +58,18 @@ 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 --- a/src/lint/linter/ArcanistRubyLinter.php +++ b/src/lint/linter/ArcanistRubyLinter.php @@ -26,6 +26,18 @@ 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 .'); }