From: epriestley Date: Thu, 30 Aug 2012 19:28:35 +0000 (-0700) Subject: Add a `willCreateRevision` event X-Git-Tag: conduit-6~145 X-Git-Url: http://git.khamidou.com/?a=commitdiff_plain;h=d79664a30d43f2406a008b85231c5c185304736c;p=arcanist.git Add a `willCreateRevision` event Summary: Adds an event prior to creation of a new revision so installs can muck around with titles, etc. I'll also update the docs. Test Plan: Ran "arc diff --trace" and observed event dispatch. Added `var_dump()` and verified $revision is a reasonable object. Reviewers: vrana, btrahan Reviewed By: vrana CC: aran, geoffberger Differential Revision: https://secure.phabricator.com/D3408 --- diff --git a/src/events/constant/ArcanistEventType.php b/src/events/constant/ArcanistEventType.php index 35a116cc..99679e11 100644 --- a/src/events/constant/ArcanistEventType.php +++ b/src/events/constant/ArcanistEventType.php @@ -19,8 +19,10 @@ final class ArcanistEventType extends PhutilEventType { const TYPE_COMMIT_WILLCOMMITSVN = 'commit.willCommitSVN'; + const TYPE_DIFF_WILLBUILDMESSAGE = 'diff.willBuildMessage'; const TYPE_DIFF_DIDBUILDMESSAGE = 'diff.didBuildMessage'; const TYPE_DIFF_WASCREATED = 'diff.wasCreated'; + const TYPE_REVISION_WILLCREATEREVISION = 'revision.willCreateRevision'; } diff --git a/src/workflow/ArcanistDiffWorkflow.php b/src/workflow/ArcanistDiffWorkflow.php index 8cc4c60b..40dba22c 100644 --- a/src/workflow/ArcanistDiffWorkflow.php +++ b/src/workflow/ArcanistDiffWorkflow.php @@ -479,6 +479,9 @@ EOTEXT echo "Updated an existing Differential revision:\n"; } else { $revision['user'] = $this->getUserPHID(); + + $revision = $this->dispatchWillCreateRevisionEvent($revision); + $future = $conduit->callMethod( 'differential.createrevision', $revision); @@ -2269,11 +2272,23 @@ EOTEXT )); } + private function dispatchWillCreateRevisionEvent(array $fields) { + $event = new PhutilEvent( + ArcanistEventType::TYPE_REVISION_WILLCREATEREVISION, + array( + 'specification' => $fields, + )); + + PhutilEventEngine::dispatchEvent($event); + + return $event->getValue('specification'); + } + private function dispatchWillBuildEvent(array $fields) { $event = new PhutilEvent( ArcanistEventType::TYPE_DIFF_WILLBUILDMESSAGE, array( - 'fields' => $fields, + 'fields' => $fields, )); PhutilEventEngine::dispatchEvent($event);