mirror of
https://we.phorge.it/source/arcanist.git
synced 2025-02-04 02:48:24 +01:00
4e3df80584
Summary: I don't feel that this linter rule belongs in the `ArcanistTextLinter`. In fact, this linter rule is quite similar to the rules provided by `ArcanistGeneratedLinter` and `ArcanistNoLintLinter` and these classes could possibly be consolidated. I have moved this linter rule to a standalone `ArcanistCommitLinter` class (which could possibly do additional lints in the future). Test Plan: Moved existing test cases. Reviewers: #blessed_reviewers, epriestley Reviewed By: #blessed_reviewers, epriestley Subscribers: epriestley, Korvin Differential Revision: https://secure.phabricator.com/D10473
56 lines
1.1 KiB
PHP
56 lines
1.1 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'),
|
|
);
|
|
}
|
|
|
|
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);
|
|
}
|
|
}
|
|
|
|
}
|