Changeset View
Changeset View
Standalone View
Standalone View
src/workflow/ArcanistAmendWorkflow.php
| Show First 20 Lines • Show All 88 Lines • ▼ Show 20 Lines | public function run() { | ||||
| if ($this->getArgument('revision')) { | if ($this->getArgument('revision')) { | ||||
| $revision_id = $this->normalizeRevisionID($this->getArgument('revision')); | $revision_id = $this->normalizeRevisionID($this->getArgument('revision')); | ||||
| } | } | ||||
| $repository_api->setBaseCommitArgumentRules('arc:this'); | $repository_api->setBaseCommitArgumentRules('arc:this'); | ||||
| $in_working_copy = $repository_api->loadWorkingCopyDifferentialRevisions( | $in_working_copy = $repository_api->loadWorkingCopyDifferentialRevisions( | ||||
| $this->getConduit(), | $this->getConduit(), | ||||
| array( | array( | ||||
| 'authors' => array($this->getUserPHID()), | |||||
| 'status' => 'status-any', | 'status' => 'status-any', | ||||
| )); | )); | ||||
| $in_working_copy = ipull($in_working_copy, null, 'id'); | $in_working_copy = ipull($in_working_copy, null, 'id'); | ||||
| if (!$revision_id) { | if (!$revision_id) { | ||||
| if (count($in_working_copy) == 0) { | if (count($in_working_copy) == 0) { | ||||
| throw new ArcanistUsageException( | throw new ArcanistUsageException( | ||||
| "No revision specified with '--revision', and no revisions found ". | "No revision specified with '--revision', and no revisions found ". | ||||
| "in the working copy. Use '--revision <id>' to specify which ". | "in the working copy. Use '--revision <id>' to specify which ". | ||||
| "revision you want to amend."); | "revision you want to amend."); | ||||
| } else if (count($in_working_copy) > 1) { | } else if (count($in_working_copy) > 1) { | ||||
| $message = "More than one revision was found in the working copy:\n". | $message = "More than one revision was found in the working copy:\n". | ||||
| $this->renderRevisionList($in_working_copy)."\n". | $this->renderRevisionList($in_working_copy)."\n". | ||||
| "Use '--revision <id>' to specify which revision you want to ". | "Use '--revision <id>' to specify which revision you want to ". | ||||
| "amend."; | "amend."; | ||||
| throw new ArcanistUsageException($message); | throw new ArcanistUsageException($message); | ||||
| } else { | } else { | ||||
| $revision_id = key($in_working_copy); | $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(); | |||||
| } | |||||
| } | |||||
| } | } | ||||
| } | } | ||||
| $conduit = $this->getConduit(); | $conduit = $this->getConduit(); | ||||
| try { | try { | ||||
| $message = $conduit->callMethodSynchronous( | $message = $conduit->callMethodSynchronous( | ||||
| 'differential.getcommitmessage', | 'differential.getcommitmessage', | ||||
| array( | array( | ||||
| ▲ Show 20 Lines • Show All 55 Lines • Show Last 20 Lines | |||||