]> khamidou — GitHub mirrors - arcanist.git/commitdiff
Arcanist - allow amending revisions by other authors in the working copy
authorBob Trahan <btrahan@phacility.com>
Tue, 8 Apr 2014 18:58:50 +0000 (11:58 -0700)
committerBob Trahan <btrahan@phacility.com>
Tue, 8 Apr 2014 18:58:50 +0000 (11:58 -0700)
Summary: Fixes T4670. Give the user an option to abort but otherwise proceed.

Test Plan: arc patch D8685 (by epriestley); arc amend

Reviewers: epriestley

Reviewed By: epriestley

Subscribers: epriestley, Korvin

Maniphest Tasks: T4670

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

src/workflow/ArcanistAmendWorkflow.php

index 3d7d3c09cf59683259d9129bf3c74e2bdd6d0fc0..fa35ee2a0d972e5f2056ac4b2f7fe1eeaf2b440c 100644 (file)
@@ -94,7 +94,6 @@ EOTEXT
     $in_working_copy = $repository_api->loadWorkingCopyDifferentialRevisions(
       $this->getConduit(),
       array(
-        'authors'   => array($this->getUserPHID()),
         'status'    => 'status-any',
       ));
     $in_working_copy = ipull($in_working_copy, null, 'id');
@@ -113,6 +112,24 @@ EOTEXT
         throw new ArcanistUsageException($message);
       } else {
         $revision_id = key($in_working_copy);
+        $revision = $in_working_copy[$revision_id];
+        if ($revision['authorPHID'] != $this->getUserPHID()) {
+          $other_author = $this->getConduit()->callMethodSynchronous(
+            'user.query',
+            array(
+              'phids' => array($revision['authorPHID']),
+            ));
+          $other_author = ipull($other_author, 'userName', 'phid');
+          $other_author = $other_author[$revision['authorPHID']];
+          $rev_title = $revision['title'];
+          $ok = phutil_console_confirm(
+            "You are amending the revision 'D{$revision_id}: {$rev_title}' ".
+            "but you are not the author. Amend this revision by ".
+            "{$other_author}?");
+          if (!$ok) {
+            throw new ArcanistUserAbortException();
+          }
+        }
       }
     }