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,18 @@ return $config->getConfigFromAnySource('lint.csslint.bin', 'csslint'); } + public function getVersion() { + list($stdout) = execx('%C --version', $this->getExecutableCommand()); + + // Extract version number from standard output. + $matches = array(); + if (preg_match('/^v(?\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,17 @@ return array_merge($mandatory_flags, $flags); } + final public function getCacheVersion() { + $version = $this->getVersion(); + + if (!$version) { + throw new Exception('Unable to parse version number.'); + } + + return $version.'-'.json_encode($this->getCommandFlags()); + } + + abstract public function getVersion(); 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('/^(?\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/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('/^(?\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,19 @@ return $config->getConfigFromAnySource('lint.phpcs.bin', 'phpcs'); } + public function getVersion() { + list($stdout) = execx('%C --version', $this->getExecutableCommand()); + + // Extract version number from standard output. + $matches = array(); + $regex = '/^PHP_CodeSniffer version (?\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,19 @@ return 'ruby'; } + public function getVersion() { + list($stdout) = execx('%C --version', $this->getExecutableCommand()); + + // Extract version number from standard output. + $matches = array(); + $regex = '/^ruby (?\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 .'); }