1
0
Fork 0
mirror of https://we.phorge.it/source/arcanist.git synced 2024-11-25 00:02: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:
Joshua Spence 2015-05-05 20:57:23 +10:00
parent c00899ad60
commit 8919a9c5b5
8 changed files with 8 additions and 122 deletions

View file

@ -93,7 +93,6 @@ phutil_register_library_map(array(
'ArcanistHgProxyClient' => 'hgdaemon/ArcanistHgProxyClient.php', 'ArcanistHgProxyClient' => 'hgdaemon/ArcanistHgProxyClient.php',
'ArcanistHgProxyServer' => 'hgdaemon/ArcanistHgProxyServer.php', 'ArcanistHgProxyServer' => 'hgdaemon/ArcanistHgProxyServer.php',
'ArcanistHgServerChannel' => 'hgdaemon/ArcanistHgServerChannel.php', 'ArcanistHgServerChannel' => 'hgdaemon/ArcanistHgServerChannel.php',
'ArcanistHookAPI' => 'repository/hookapi/ArcanistHookAPI.php',
'ArcanistInstallCertificateWorkflow' => 'workflow/ArcanistInstallCertificateWorkflow.php', 'ArcanistInstallCertificateWorkflow' => 'workflow/ArcanistInstallCertificateWorkflow.php',
'ArcanistJSHintLinter' => 'lint/linter/ArcanistJSHintLinter.php', 'ArcanistJSHintLinter' => 'lint/linter/ArcanistJSHintLinter.php',
'ArcanistJSHintLinterTestCase' => 'lint/linter/__tests__/ArcanistJSHintLinterTestCase.php', 'ArcanistJSHintLinterTestCase' => 'lint/linter/__tests__/ArcanistJSHintLinterTestCase.php',
@ -172,7 +171,6 @@ phutil_register_library_map(array(
'ArcanistStartWorkflow' => 'workflow/ArcanistStartWorkflow.php', 'ArcanistStartWorkflow' => 'workflow/ArcanistStartWorkflow.php',
'ArcanistStopWorkflow' => 'workflow/ArcanistStopWorkflow.php', 'ArcanistStopWorkflow' => 'workflow/ArcanistStopWorkflow.php',
'ArcanistSubversionAPI' => 'repository/api/ArcanistSubversionAPI.php', 'ArcanistSubversionAPI' => 'repository/api/ArcanistSubversionAPI.php',
'ArcanistSubversionHookAPI' => 'repository/hookapi/ArcanistSubversionHookAPI.php',
'ArcanistSummaryLintRenderer' => 'lint/renderer/ArcanistSummaryLintRenderer.php', 'ArcanistSummaryLintRenderer' => 'lint/renderer/ArcanistSummaryLintRenderer.php',
'ArcanistTasksWorkflow' => 'workflow/ArcanistTasksWorkflow.php', 'ArcanistTasksWorkflow' => 'workflow/ArcanistTasksWorkflow.php',
'ArcanistTestCase' => 'infrastructure/testing/ArcanistTestCase.php', 'ArcanistTestCase' => 'infrastructure/testing/ArcanistTestCase.php',
@ -353,7 +351,6 @@ phutil_register_library_map(array(
'ArcanistStartWorkflow' => 'ArcanistPhrequentWorkflow', 'ArcanistStartWorkflow' => 'ArcanistPhrequentWorkflow',
'ArcanistStopWorkflow' => 'ArcanistPhrequentWorkflow', 'ArcanistStopWorkflow' => 'ArcanistPhrequentWorkflow',
'ArcanistSubversionAPI' => 'ArcanistRepositoryAPI', 'ArcanistSubversionAPI' => 'ArcanistRepositoryAPI',
'ArcanistSubversionHookAPI' => 'ArcanistHookAPI',
'ArcanistSummaryLintRenderer' => 'ArcanistLintRenderer', 'ArcanistSummaryLintRenderer' => 'ArcanistLintRenderer',
'ArcanistTasksWorkflow' => 'ArcanistWorkflow', 'ArcanistTasksWorkflow' => 'ArcanistWorkflow',
'ArcanistTestCase' => 'ArcanistPhutilTestCase', 'ArcanistTestCase' => 'ArcanistPhutilTestCase',

View file

@ -57,8 +57,6 @@ abstract class ArcanistLintEngine {
private $minimumSeverity = ArcanistLintSeverity::SEVERITY_DISABLED; private $minimumSeverity = ArcanistLintSeverity::SEVERITY_DISABLED;
private $changedLines = array(); private $changedLines = array();
private $commitHookMode = false;
private $hookAPI;
private $enableAsyncLint = false; private $enableAsyncLint = false;
private $postponedLinters = array(); private $postponedLinters = array();
@ -115,20 +113,6 @@ abstract class ArcanistLintEngine {
return $this; 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) { final public function setEnableAsyncLint($enable_async_lint) {
$this->enableAsyncLint = $enable_async_lint; $this->enableAsyncLint = $enable_async_lint;
return $this; return $this;
@ -140,42 +124,21 @@ abstract class ArcanistLintEngine {
final public function loadData($path) { final public function loadData($path) {
if (!isset($this->fileData[$path])) { if (!isset($this->fileData[$path])) {
if ($this->getCommitHookMode()) {
$this->fileData[$path] = $this->getHookAPI()
->getCurrentFileData($path);
} else {
$disk_path = $this->getFilePathOnDisk($path); $disk_path = $this->getFilePathOnDisk($path);
$this->fileData[$path] = Filesystem::readFile($disk_path); $this->fileData[$path] = Filesystem::readFile($disk_path);
} }
}
return $this->fileData[$path]; return $this->fileData[$path];
} }
public function pathExists($path) { public function pathExists($path) {
if ($this->getCommitHookMode()) {
$file_data = $this->loadData($path);
return ($file_data !== null);
} else {
$disk_path = $this->getFilePathOnDisk($path); $disk_path = $this->getFilePathOnDisk($path);
return Filesystem::pathExists($disk_path); return Filesystem::pathExists($disk_path);
} }
}
final public function isDirectory($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); $disk_path = $this->getFilePathOnDisk($path);
return is_dir($disk_path); return is_dir($disk_path);
} }
}
final public function isBinaryFile($path) { final public function isBinaryFile($path) {
try { try {
@ -202,10 +165,6 @@ abstract class ArcanistLintEngine {
return $this; return $this;
} }
final public function getCommitHookMode() {
return $this->commitHookMode;
}
final public function run() { final public function run() {
$linters = $this->buildLinters(); $linters = $this->buildLinters();
if (!$linters) { if (!$linters) {
@ -328,9 +287,6 @@ abstract class ArcanistLintEngine {
$cache_granularity, $cache_granularity,
$repository_version) { $repository_version) {
if ($this->commitHookMode) {
return false;
}
switch ($cache_granularity) { switch ($cache_granularity) {
case ArcanistLinter::GRANULARITY_FILE: case ArcanistLinter::GRANULARITY_FILE:
return true; return true;

View file

@ -386,11 +386,10 @@ abstract class ArcanistLinter {
} }
final protected function addLintMessage(ArcanistLintMessage $message) { final protected function addLintMessage(ArcanistLintMessage $message) {
if (!$this->getEngine()->getCommitHookMode()) {
$root = $this->getEngine()->getWorkingCopy()->getProjectRoot(); $root = $this->getEngine()->getWorkingCopy()->getProjectRoot();
$path = Filesystem::resolvePath($message->getPath(), $root); $path = Filesystem::resolvePath($message->getPath(), $root);
$message->setPath(Filesystem::readablePath($path, $root)); $message->setPath(Filesystem::readablePath($path, $root));
}
$this->messages[] = $message; $this->messages[] = $message;
return $message; return $message;
} }

View file

@ -76,7 +76,6 @@ abstract class ArcanistLinterTestCase extends ArcanistPhutilTestCase {
PhutilTypeSpec::checkMap( PhutilTypeSpec::checkMap(
$config, $config,
array( array(
'hook' => 'optional bool',
'config' => 'optional map<string, wild>', 'config' => 'optional map<string, wild>',
'path' => 'optional string', 'path' => 'optional string',
'mode' => 'optional string', 'mode' => 'optional string',
@ -114,8 +113,6 @@ abstract class ArcanistLinterTestCase extends ArcanistPhutilTestCase {
$engine->setWorkingCopy($working_copy); $engine->setWorkingCopy($working_copy);
$engine->setConfigurationManager($configuration_manager); $engine->setConfigurationManager($configuration_manager);
$engine->setCommitHookMode(idx($config, 'hook', false));
$path_name = idx($config, 'path', $path); $path_name = idx($config, 'path', $path);
$engine->setPaths(array($path_name)); $engine->setPaths(array($path_name));

View file

@ -18,8 +18,3 @@ warning:7:12
warning:9:15 warning:9:15
warning:10:11 warning:10:11
warning:11:12 warning:11:12
~~~~~~~~~~
~~~~~~~~~~
{
"hook" : true
}

View file

@ -17,10 +17,6 @@ final class ArcanistGitAPI extends ArcanistRepositoryAPI {
private $symbolicHeadCommit; private $symbolicHeadCommit;
private $resolvedHeadCommit; private $resolvedHeadCommit;
public static function newHookAPI($root) {
return new ArcanistGitAPI($root);
}
protected function buildLocalFuture(array $argv) { protected function buildLocalFuture(array $argv) {
$argv[0] = 'git '.$argv[0]; $argv[0] = 'git '.$argv[0];
@ -704,15 +700,6 @@ final class ArcanistGitAPI extends ArcanistRepositoryAPI {
return $this; 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) { private function parseGitStatus($status, $full = false) {
static $flags = array( static $flags = array(
'A' => self::FLAG_ADDED, 'A' => self::FLAG_ADDED,

View file

@ -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);
}

View file

@ -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);
}
}