Skip to content

Instantly share code, notes, and snippets.

@quentindemetz
Last active January 11, 2020 22:54
Show Gist options
  • Save quentindemetz/5c49a404b7efcfc17fbb to your computer and use it in GitHub Desktop.
Save quentindemetz/5c49a404b7efcfc17fbb to your computer and use it in GitHub Desktop.
Pre-commit compatible Arcanist Lint Engine
{
"phabricator.uri" : "/url/to/phabricator/instance",
"load" : [
"../path/to/below/phabricator/module"
],
"lint.engine" : "PreCommitLintEngine"
}

pre-commit/pre-commit compatible hook classes for arcanist.

Insert them in a phutil library, as specified here

<?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;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment