mirror of
https://we.phorge.it/source/arcanist.git
synced 2025-02-04 02:48:24 +01:00
3152db6cce
Summary: The expectation is that this linter only raises errors. Test Plan: This is mostly theoretical. Reviewers: epriestley, #blessed_reviewers Reviewed By: epriestley, #blessed_reviewers Subscribers: Korvin, epriestley Differential Revision: https://secure.phabricator.com/D11331
60 lines
1.2 KiB
PHP
60 lines
1.2 KiB
PHP
<?php
|
|
|
|
final class ArcanistCommitLinter extends ArcanistLinter {
|
|
|
|
const LINT_NO_COMMIT = 1;
|
|
|
|
public function getInfoName() {
|
|
return pht('Commit Linter');
|
|
}
|
|
|
|
public function getInfoDescription() {
|
|
return pht('Ensures that specially marked files are not committed.');
|
|
}
|
|
|
|
public function getLinterPriority() {
|
|
return 0.5;
|
|
}
|
|
|
|
public function getLinterName() {
|
|
return 'COMMIT';
|
|
}
|
|
|
|
public function getLinterConfigurationName() {
|
|
return 'commit';
|
|
}
|
|
|
|
public function getLintNameMap() {
|
|
return array(
|
|
self::LINT_NO_COMMIT => pht('Explicit %s', '@no'.'commit'),
|
|
);
|
|
}
|
|
|
|
protected function canCustomizeLintSeverities() {
|
|
return false;
|
|
}
|
|
|
|
public function lintPath($path) {
|
|
if ($this->getEngine()->getCommitHookMode()) {
|
|
$this->lintNoCommit($path);
|
|
}
|
|
}
|
|
|
|
private function lintNoCommit($path) {
|
|
$data = $this->getData($path);
|
|
|
|
$deadly = '@no'.'commit';
|
|
$offset = strpos($data, $deadly);
|
|
|
|
if ($offset !== false) {
|
|
$this->raiseLintAtOffset(
|
|
$offset,
|
|
self::LINT_NO_COMMIT,
|
|
pht(
|
|
'This file is explicitly marked as "%s", which blocks commits.',
|
|
$deadly),
|
|
$deadly);
|
|
}
|
|
}
|
|
|
|
}
|