]> khamidou — GitHub mirrors - arcanist.git/commitdiff
Make "arc land" support landing someone else's code that got there via arc patch
authorBob Trahan <btrahan@phacility.com>
Mon, 7 Apr 2014 18:44:14 +0000 (11:44 -0700)
committerBob Trahan <btrahan@phacility.com>
Mon, 7 Apr 2014 18:44:14 +0000 (11:44 -0700)
Summary: Ref T4670.

Test Plan: arc patch D8685; arc land --hold; verified i got a nice message asking me to be sure i wanted to land epriestley's code

Reviewers: epriestley

Reviewed By: epriestley

Subscribers: epriestley, Korvin

Maniphest Tasks: T4670

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

src/workflow/ArcanistLandWorkflow.php

index be069800523e424b1c78ac779e3041dffb36eb4d..1376e9f6de7865431288fea63b6430c6d8e96fa0 100644 (file)
@@ -405,9 +405,7 @@ EOTEXT
     } else {
       $revisions = $repository_api->loadWorkingCopyDifferentialRevisions(
         $this->getConduit(),
-        array(
-          'authors' => array($this->getUserPHID()),
-        ));
+        array());
     }
 
     if (!count($revisions)) {
@@ -435,6 +433,22 @@ EOTEXT
     $rev_title = $this->revision['title'];
     $rev_auxiliary = idx($this->revision, 'auxiliary', array());
 
+    if ($this->revision['authorPHID'] != $this->getUserPHID()) {
+      $other_author = $this->getConduit()->callMethodSynchronous(
+        'user.query',
+        array(
+          'phids' => array($this->revision['authorPHID']),
+        ));
+      $other_author = ipull($other_author, 'userName', 'phid');
+      $other_author = $other_author[$this->revision['authorPHID']];
+      $ok = phutil_console_confirm(
+        "This {$this->branchType} has revision 'D{$rev_id}: {$rev_title}' ".
+        "but you are not the author. Land this revision by {$other_author}?");
+      if (!$ok) {
+        throw new ArcanistUserAbortException();
+      }
+    }
+
     if ($rev_status != ArcanistDifferentialRevisionStatus::ACCEPTED) {
       $ok = phutil_console_confirm(
         "Revision 'D{$rev_id}: {$rev_title}' has not been ".