]> khamidou — GitHub mirrors - arcanist.git/commitdiff
Warn user about specifying reviewers that are away
authorvrana <jakubv@fb.com>
Fri, 18 May 2012 02:27:24 +0000 (19:27 -0700)
committervrana <jakubv@fb.com>
Fri, 18 May 2012 07:04:29 +0000 (00:04 -0700)
Summary:
There are different options how to implement this:
We can also generate the warning in `validateField()` and handle it in all callsites.
This is sufficient for me and simple enough.

Test Plan: `arc diff` revision with reviewer away/not away.

Reviewers: btrahan, jungejason

Reviewed By: jungejason

CC: epriestley, aran
Differential Revision: https://secure.phabricator.com/D2493

src/workflow/diff/ArcanistDiffWorkflow.php

index 47ca9f89c67bac652151ee4a0c8fd1cb9ba93d28..86ea239401b2ec079e463d04468b56a3aea4c75f 100644 (file)
@@ -1538,6 +1538,24 @@ EOTEXT
     } else if (in_array($this->getUserPHID(), $reviewers)) {
       throw new ArcanistUsageException(
         "You can not be a reviewer for your own revision.");
+    } else {
+      $statuses = $this->getConduit()->callMethodSynchronous(
+        'user.getcurrentstatus',
+        array(
+          'userPHIDs' => $reviewers,
+        ));
+      foreach ($statuses as $key => $status) {
+        if ($status['status'] != 'away') {
+          unset($statuses[$key]);
+        }
+      }
+      if (count($statuses) == count($reviewers)) {
+        $confirm = "All reviewers are away. Continue anyway?";
+        if (!phutil_console_confirm($confirm)) {
+          throw new ArcanistUsageException(
+            'Specify available reviewers and retry.');
+        }
+      }
     }
   }