]> khamidou — GitHub mirrors - arcanist.git/commitdiff
Make --conduit-token work without requiring .arcrc
authorepriestley <git@epriestley.com>
Thu, 7 May 2015 18:09:58 +0000 (11:09 -0700)
committerepriestley <git@epriestley.com>
Thu, 7 May 2015 18:09:58 +0000 (11:09 -0700)
Summary:
Ref T5955. This logic is a little cleaner than the previous version.

Don't require `~/.arcrc` to exist if the caller provides `--conduit-token`.

Test Plan:
  - Made calls with `--conduit-token` and no `~/.arcrc`.
  - Made calls with `--conduit-token` and a normal `~/.arcrc`.
  - Made calls with normal `arc`.

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: mbishopim3, epriestley

Maniphest Tasks: T5955

Differential Revision: https://secure.phabricator.com/D12750

scripts/arcanist.php
src/workflow/ArcanistWorkflow.php

index 89b6d2c6d1b1a34a51aadea09c69469e0e68f024..8df56284d93a4961d69c10380e24264252a15121 100755 (executable)
@@ -204,9 +204,6 @@ try {
   if ($force_conduit_version) {
     $workflow->forceConduitVersion($force_conduit_version);
   }
-  if ($force_token) {
-    $workflow->forceConduitToken($force_token);
-  }
   if ($conduit_timeout) {
     $workflow->setConduitTimeout($conduit_timeout);
   }
@@ -316,6 +313,9 @@ try {
   $user_name = idx($host_config, 'user');
   $certificate = idx($host_config, 'cert');
   $conduit_token = idx($host_config, 'token');
+  if ($force_token) {
+    $conduit_token = $force_token;
+  }
 
   $description = implode(' ', $original_argv);
   $credentials = array(
index ab90ed3d865fe409e6cd1774a7e9e167fa479907..d873ae5d0edfe845f61484866e629cb1f3451ba0 100644 (file)
@@ -48,7 +48,6 @@ abstract class ArcanistWorkflow extends Phobject {
   private $conduitCredentials;
   private $conduitAuthenticated;
   private $forcedConduitVersion;
-  private $forcedConduitToken;
   private $conduitTimeout;
 
   private $userPHID;
@@ -252,21 +251,6 @@ abstract class ArcanistWorkflow extends Phobject {
   }
 
 
-  /**
-   * Force use of a specific API token.
-   *
-   * Controlled by the --conduit-token flag.
-   *
-   * @param string API token to use.
-   * @return this
-   * @task conduit
-   */
-  final public function forceConduitToken($token) {
-    $this->forcedConduitToken = $token;
-    return $this;
-  }
-
-
   /**
    * Get the protocol version the client should identify with.
    *
@@ -341,13 +325,7 @@ abstract class ArcanistWorkflow extends Phobject {
       // If we have `token`, this server supports the simpler, new-style
       // token-based authentication. Use that instead of all the certificate
       // stuff.
-      $token = null;
-      if (isset($credentials['token'])) {
-        $token = $credentials['token'];
-      }
-      if ($this->forcedConduitToken) {
-        $token = $this->forcedConduitToken;
-      }
+      $token = idx($credentials, 'token');
       if (strlen($token)) {
         $conduit = $this->getConduit();