Page MenuHomePhabricator

D2754.diff
No OneTemporary

D2754.diff

diff --git a/.arclint b/.arclint
--- a/.arclint
+++ b/.arclint
@@ -14,6 +14,7 @@
},
"autopep8": {
"type": "autopep8",
+ "version": ">=1.3.4",
"include": "(\\.py$)"
},
"flake8": {
diff --git a/arcanist/linter/AutoPEP8Linter.php b/arcanist/linter/AutoPEP8Linter.php
--- a/arcanist/linter/AutoPEP8Linter.php
+++ b/arcanist/linter/AutoPEP8Linter.php
@@ -35,6 +35,29 @@
public function getDefaultBinary() {
return 'autopep8';
}
+
+ public function getVersion() {
+ list($stdout, $stderr) = execx('%C --version',
+ $this->getExecutableCommand());
+ $matches = array();
+
+ /* Support a.b or a.b.c version numbering scheme */
+ $regex = '/^autopep8 (?P<version>\d+\.\d+(?:\.\d+)?)/';
+
+ /*
+ * Old autopep8 output the version to stdout, newer output to stderr.
+ * Try both to determine the version.
+ */
+ if (preg_match($regex, $stdout, $matches)) {
+ return $matches['version'];
+ }
+ if (preg_match($regex, $stderr, $matches)) {
+ return $matches['version'];
+ }
+
+ return false;
+ }
+
public function getInstallInstructions() {
return pht('Make sure autopep8 is in directory specified by $PATH');

File Metadata

Mime Type
text/plain
Expires
Sat, Dec 28, 19:38 (8 h, 23 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
4844974
Default Alt Text
D2754.diff (1 KB)

Event Timeline