]> khamidou — GitHub mirrors - arcanist.git/commitdiff
Add a `willCreateRevision` event
authorepriestley <git@epriestley.com>
Thu, 30 Aug 2012 19:28:35 +0000 (12:28 -0700)
committerepriestley <git@epriestley.com>
Thu, 30 Aug 2012 19:28:35 +0000 (12:28 -0700)
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

src/events/constant/ArcanistEventType.php
src/workflow/ArcanistDiffWorkflow.php

index 35a116cc514915f70decd1078610913628b1d481..99679e11cc56a572064088ff1e8716097b719b93 100644 (file)
 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';
 }
index 8cc4c60b7cb2d6687d716ac4a546160777257e93..40dba22c307844f80fabe0bd355303e2d013bd3f 100644 (file)
@@ -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);