mirror of
https://we.phorge.it/source/arcanist.git
synced 2024-11-24 15:52:40 +01:00
Remove hook functionality
Summary: Fixes T7674. Remove remaining commit hook functionality. Test Plan: Unit tests still pass? Reviewers: #blessed_reviewers, epriestley Reviewed By: #blessed_reviewers, epriestley Subscribers: Korvin, epriestley Maniphest Tasks: T7674 Differential Revision: https://secure.phabricator.com/D12698
This commit is contained in:
parent
c00899ad60
commit
8919a9c5b5
8 changed files with 8 additions and 122 deletions
|
@ -93,7 +93,6 @@ phutil_register_library_map(array(
|
|||
'ArcanistHgProxyClient' => 'hgdaemon/ArcanistHgProxyClient.php',
|
||||
'ArcanistHgProxyServer' => 'hgdaemon/ArcanistHgProxyServer.php',
|
||||
'ArcanistHgServerChannel' => 'hgdaemon/ArcanistHgServerChannel.php',
|
||||
'ArcanistHookAPI' => 'repository/hookapi/ArcanistHookAPI.php',
|
||||
'ArcanistInstallCertificateWorkflow' => 'workflow/ArcanistInstallCertificateWorkflow.php',
|
||||
'ArcanistJSHintLinter' => 'lint/linter/ArcanistJSHintLinter.php',
|
||||
'ArcanistJSHintLinterTestCase' => 'lint/linter/__tests__/ArcanistJSHintLinterTestCase.php',
|
||||
|
@ -172,7 +171,6 @@ phutil_register_library_map(array(
|
|||
'ArcanistStartWorkflow' => 'workflow/ArcanistStartWorkflow.php',
|
||||
'ArcanistStopWorkflow' => 'workflow/ArcanistStopWorkflow.php',
|
||||
'ArcanistSubversionAPI' => 'repository/api/ArcanistSubversionAPI.php',
|
||||
'ArcanistSubversionHookAPI' => 'repository/hookapi/ArcanistSubversionHookAPI.php',
|
||||
'ArcanistSummaryLintRenderer' => 'lint/renderer/ArcanistSummaryLintRenderer.php',
|
||||
'ArcanistTasksWorkflow' => 'workflow/ArcanistTasksWorkflow.php',
|
||||
'ArcanistTestCase' => 'infrastructure/testing/ArcanistTestCase.php',
|
||||
|
@ -353,7 +351,6 @@ phutil_register_library_map(array(
|
|||
'ArcanistStartWorkflow' => 'ArcanistPhrequentWorkflow',
|
||||
'ArcanistStopWorkflow' => 'ArcanistPhrequentWorkflow',
|
||||
'ArcanistSubversionAPI' => 'ArcanistRepositoryAPI',
|
||||
'ArcanistSubversionHookAPI' => 'ArcanistHookAPI',
|
||||
'ArcanistSummaryLintRenderer' => 'ArcanistLintRenderer',
|
||||
'ArcanistTasksWorkflow' => 'ArcanistWorkflow',
|
||||
'ArcanistTestCase' => 'ArcanistPhutilTestCase',
|
||||
|
|
|
@ -57,8 +57,6 @@ abstract class ArcanistLintEngine {
|
|||
private $minimumSeverity = ArcanistLintSeverity::SEVERITY_DISABLED;
|
||||
|
||||
private $changedLines = array();
|
||||
private $commitHookMode = false;
|
||||
private $hookAPI;
|
||||
|
||||
private $enableAsyncLint = false;
|
||||
private $postponedLinters = array();
|
||||
|
@ -115,20 +113,6 @@ abstract class ArcanistLintEngine {
|
|||
return $this;
|
||||
}
|
||||
|
||||
final public function setCommitHookMode($mode) {
|
||||
$this->commitHookMode = $mode;
|
||||
return $this;
|
||||
}
|
||||
|
||||
final public function setHookAPI(ArcanistHookAPI $hook_api) {
|
||||
$this->hookAPI = $hook_api;
|
||||
return $this;
|
||||
}
|
||||
|
||||
final public function getHookAPI() {
|
||||
return $this->hookAPI;
|
||||
}
|
||||
|
||||
final public function setEnableAsyncLint($enable_async_lint) {
|
||||
$this->enableAsyncLint = $enable_async_lint;
|
||||
return $this;
|
||||
|
@ -140,41 +124,20 @@ abstract class ArcanistLintEngine {
|
|||
|
||||
final public function loadData($path) {
|
||||
if (!isset($this->fileData[$path])) {
|
||||
if ($this->getCommitHookMode()) {
|
||||
$this->fileData[$path] = $this->getHookAPI()
|
||||
->getCurrentFileData($path);
|
||||
} else {
|
||||
$disk_path = $this->getFilePathOnDisk($path);
|
||||
$this->fileData[$path] = Filesystem::readFile($disk_path);
|
||||
}
|
||||
}
|
||||
return $this->fileData[$path];
|
||||
}
|
||||
|
||||
public function pathExists($path) {
|
||||
if ($this->getCommitHookMode()) {
|
||||
$file_data = $this->loadData($path);
|
||||
return ($file_data !== null);
|
||||
} else {
|
||||
$disk_path = $this->getFilePathOnDisk($path);
|
||||
return Filesystem::pathExists($disk_path);
|
||||
}
|
||||
$disk_path = $this->getFilePathOnDisk($path);
|
||||
return Filesystem::pathExists($disk_path);
|
||||
}
|
||||
|
||||
final public function isDirectory($path) {
|
||||
if ($this->getCommitHookMode()) {
|
||||
// TODO: This won't get the right result in every case (we need more
|
||||
// metadata) but should almost always be correct.
|
||||
try {
|
||||
$this->loadData($path);
|
||||
return false;
|
||||
} catch (Exception $ex) {
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
$disk_path = $this->getFilePathOnDisk($path);
|
||||
return is_dir($disk_path);
|
||||
}
|
||||
$disk_path = $this->getFilePathOnDisk($path);
|
||||
return is_dir($disk_path);
|
||||
}
|
||||
|
||||
final public function isBinaryFile($path) {
|
||||
|
@ -202,10 +165,6 @@ abstract class ArcanistLintEngine {
|
|||
return $this;
|
||||
}
|
||||
|
||||
final public function getCommitHookMode() {
|
||||
return $this->commitHookMode;
|
||||
}
|
||||
|
||||
final public function run() {
|
||||
$linters = $this->buildLinters();
|
||||
if (!$linters) {
|
||||
|
@ -328,9 +287,6 @@ abstract class ArcanistLintEngine {
|
|||
$cache_granularity,
|
||||
$repository_version) {
|
||||
|
||||
if ($this->commitHookMode) {
|
||||
return false;
|
||||
}
|
||||
switch ($cache_granularity) {
|
||||
case ArcanistLinter::GRANULARITY_FILE:
|
||||
return true;
|
||||
|
|
|
@ -386,11 +386,10 @@ abstract class ArcanistLinter {
|
|||
}
|
||||
|
||||
final protected function addLintMessage(ArcanistLintMessage $message) {
|
||||
if (!$this->getEngine()->getCommitHookMode()) {
|
||||
$root = $this->getEngine()->getWorkingCopy()->getProjectRoot();
|
||||
$path = Filesystem::resolvePath($message->getPath(), $root);
|
||||
$message->setPath(Filesystem::readablePath($path, $root));
|
||||
}
|
||||
$root = $this->getEngine()->getWorkingCopy()->getProjectRoot();
|
||||
$path = Filesystem::resolvePath($message->getPath(), $root);
|
||||
$message->setPath(Filesystem::readablePath($path, $root));
|
||||
|
||||
$this->messages[] = $message;
|
||||
return $message;
|
||||
}
|
||||
|
|
|
@ -76,7 +76,6 @@ abstract class ArcanistLinterTestCase extends ArcanistPhutilTestCase {
|
|||
PhutilTypeSpec::checkMap(
|
||||
$config,
|
||||
array(
|
||||
'hook' => 'optional bool',
|
||||
'config' => 'optional map<string, wild>',
|
||||
'path' => 'optional string',
|
||||
'mode' => 'optional string',
|
||||
|
@ -114,8 +113,6 @@ abstract class ArcanistLinterTestCase extends ArcanistPhutilTestCase {
|
|||
$engine->setWorkingCopy($working_copy);
|
||||
$engine->setConfigurationManager($configuration_manager);
|
||||
|
||||
$engine->setCommitHookMode(idx($config, 'hook', false));
|
||||
|
||||
$path_name = idx($config, 'path', $path);
|
||||
$engine->setPaths(array($path_name));
|
||||
|
||||
|
|
|
@ -18,8 +18,3 @@ warning:7:12
|
|||
warning:9:15
|
||||
warning:10:11
|
||||
warning:11:12
|
||||
~~~~~~~~~~
|
||||
~~~~~~~~~~
|
||||
{
|
||||
"hook" : true
|
||||
}
|
||||
|
|
|
@ -17,10 +17,6 @@ final class ArcanistGitAPI extends ArcanistRepositoryAPI {
|
|||
private $symbolicHeadCommit;
|
||||
private $resolvedHeadCommit;
|
||||
|
||||
public static function newHookAPI($root) {
|
||||
return new ArcanistGitAPI($root);
|
||||
}
|
||||
|
||||
protected function buildLocalFuture(array $argv) {
|
||||
$argv[0] = 'git '.$argv[0];
|
||||
|
||||
|
@ -704,15 +700,6 @@ final class ArcanistGitAPI extends ArcanistRepositoryAPI {
|
|||
return $this;
|
||||
}
|
||||
|
||||
public function getPreReceiveHookStatus($old_ref, $new_ref) {
|
||||
$options = $this->getDiffBaseOptions();
|
||||
list($stdout) = $this->execxLocal(
|
||||
"diff {$options} --raw %s %s --",
|
||||
$old_ref,
|
||||
$new_ref);
|
||||
return $this->parseGitStatus($stdout, $full = true);
|
||||
}
|
||||
|
||||
private function parseGitStatus($status, $full = false) {
|
||||
static $flags = array(
|
||||
'A' => self::FLAG_ADDED,
|
||||
|
|
|
@ -1,9 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* API while running in the context of a commit hook.
|
||||
*/
|
||||
abstract class ArcanistHookAPI {
|
||||
abstract public function getCurrentFileData($path);
|
||||
abstract public function getUpstreamFileData($path);
|
||||
}
|
|
@ -1,36 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Interfaces with Subversion while running as a commit hook.
|
||||
*/
|
||||
final class ArcanistSubversionHookAPI extends ArcanistHookAPI {
|
||||
|
||||
protected $root;
|
||||
protected $transaction;
|
||||
protected $repository;
|
||||
|
||||
public function __construct($root, $transaction, $repository) {
|
||||
$this->root = $root;
|
||||
$this->transaction = $transaction;
|
||||
$this->repository = $repository;
|
||||
}
|
||||
|
||||
public function getCurrentFileData($path) {
|
||||
list($err, $file) = exec_manual(
|
||||
'svnlook cat --transaction %s %s %s',
|
||||
$this->transaction,
|
||||
$this->repository,
|
||||
$path);
|
||||
|
||||
return ($err? null : $file);
|
||||
}
|
||||
|
||||
public function getUpstreamFileData($path) {
|
||||
list($err, $file) = exec_manual(
|
||||
'svnlook cat %s %s',
|
||||
$this->repository,
|
||||
$this->root."/$path");
|
||||
return ($err ? null : $file);
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in a new issue