]> khamidou — GitHub mirrors - arcanist.git/commitdiff
Remove hook functionality
authorJoshua Spence <josh@joshuaspence.com>
Tue, 5 May 2015 10:57:23 +0000 (20:57 +1000)
committerJoshua Spence <josh@joshuaspence.com>
Tue, 5 May 2015 11:10:47 +0000 (21:10 +1000)
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

src/__phutil_library_map__.php
src/lint/engine/ArcanistLintEngine.php
src/lint/linter/ArcanistLinter.php
src/lint/linter/__tests__/ArcanistLinterTestCase.php
src/lint/linter/__tests__/spelling/spell.lint-test
src/repository/api/ArcanistGitAPI.php
src/repository/hookapi/ArcanistHookAPI.php [deleted file]
src/repository/hookapi/ArcanistSubversionHookAPI.php [deleted file]

index a9d9e0ea99d426456df0acaca93510a26d3957b1..6b04b74340976457f4597a4b18a501c9d15fbb62 100644 (file)
@@ -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',
index 8a4d1212e194c2b415605e95f39e3e980bcd015b..29cf13d6fcb407a36683745c249e369a0b63ef96 100644 (file)
@@ -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;
index 23a7f7a6ce552610562c9b1e29aacebd9a38922e..41e27c1c042325fce0d7724789dad06b6c6ade16 100644 (file)
@@ -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;
   }
index 61a50b14dba34d1bc538c65de38c7a68917fe403..322dca7f8e7e52931a4a1774c23699de39e98cc9 100644 (file)
@@ -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));
 
index a992d1f3c89e4e808a55acbfe8c4ab2f527d7ce2..367ba8a573f316366af7a2730e13e22d46203fee 100644 (file)
@@ -18,8 +18,3 @@ warning:7:12
 warning:9:15
 warning:10:11
 warning:11:12
-~~~~~~~~~~
-~~~~~~~~~~
-{
-  "hook" : true
-}
index f57878968e5b750b27ef0ef1b46011406a8463e8..5377ebafe824bd0508bc84b473140ab68b9ff3f7 100644 (file)
@@ -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,
diff --git a/src/repository/hookapi/ArcanistHookAPI.php b/src/repository/hookapi/ArcanistHookAPI.php
deleted file mode 100644 (file)
index 2c9a217..0000000
+++ /dev/null
@@ -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);
-}
diff --git a/src/repository/hookapi/ArcanistSubversionHookAPI.php b/src/repository/hookapi/ArcanistSubversionHookAPI.php
deleted file mode 100644 (file)
index 95b80c8..0000000
+++ /dev/null
@@ -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);
-  }
-
-}