pre-commit/pre-commit compatible hook classes for arcanist.
Insert them in a phutil library, as specified here
{ | |
"phabricator.uri" : "/url/to/phabricator/instance", | |
"load" : [ | |
"../path/to/below/phabricator/module" | |
], | |
"lint.engine" : "PreCommitLintEngine" | |
} |
<?php | |
final class PreCommitLintEngine extends ArcanistLintEngine { | |
public function buildLinters() { | |
$paths = $this->getPaths(); | |
$linter = new PreCommitLinter(); | |
foreach($paths as $path) { | |
$linter->addPath($paths[0]); | |
} | |
return array( | |
$linter | |
); | |
} | |
} |
<?php | |
final class PreCommitLinter extends ArcanistExternalLinter { | |
public function getLinterName() { | |
return 'PreCommitLinter'; | |
} | |
public function getDefaultBinary() { | |
return 'pre-commit'; | |
} | |
protected function getPathArgumentForLinterFuture($path) { | |
return 'run --file ' . $path; | |
} | |
public function getInstallInstructions() { | |
return pht('run pip install pre-commit'); | |
} | |
protected function parseLinterOutput($path, $err, $stdout, $stderr) { | |
if(! $err) return []; | |
return false; | |
} | |
} |