]> khamidou — GitHub mirrors - arcanist.git/commitdiff
Prohibit creation of command-line revisions with yourself as the reviewer
authorepriestley <git@epriestley.com>
Thu, 30 Jun 2011 20:51:24 +0000 (13:51 -0700)
committerepriestley <git@epriestley.com>
Sun, 3 Jul 2011 18:50:54 +0000 (11:50 -0700)
Summary:
We do this check on the web interface but not from the CLI.

Also clean up some GUID/PHID stuff (eventually all GUID references should be
replaced with PHID, although they mean the same thing).

Test Plan: Tried to create a revision with myself on the reviewer line, got
called out.
Reviewed By: jungejason
Reviewers: moskov, jungejason, tuomaspelkonen, aran
CC: aran, jungejason
Differential Revision: 564

src/workflow/diff/ArcanistDiffWorkflow.php

index e80fb0d5d8c83c3fcac14ccd858ff37e6e2ec495..0f376827a02807a48663ac7730e17ddb267f5203 100644 (file)
@@ -886,7 +886,7 @@ EOTEXT
 
       // TODO: Move this all behind Conduit.
       if (!$message->getRevisionID()) {
-        if ($message->getFieldValue('reviewedByGUIDs')) {
+        if ($message->getFieldValue('reviewedByPHIDs')) {
           $problems[$key][] = new ArcanistUsageException(
             "When creating or updating a revision, use the 'Reviewers:' ".
             "field to specify reviewers, not 'Reviewed By:'. After the ".
@@ -949,12 +949,15 @@ EOTEXT
     }
 
     if ($blessed) {
-      if (!$blessed->getFieldValue('reviewerGUIDs') &&
-          !$blessed->getFieldValue('reviewerPHIDs')) {
+      $reviewers = $blessed->getFieldValue('reviewerPHIDs');
+      if (!$reviewers) {
         $message = "You have not specified any reviewers. Continue anyway?";
         if (!phutil_console_confirm($message)) {
           throw new ArcanistUsageException('Specify reviewers and retry.');
         }
+      } else if (in_array($this->getUserGUID(), $reviewers)) {
+        throw new ArcanistUsageException(
+          "You can not be a reviewer for your own revision.");
       }
     }