]> khamidou — GitHub mirrors - arcanist.git/commitdiff
Dispatch a "diff.willBuildMessage" event from Arcanist conduit-4
authorepriestley <git@epriestley.com>
Sun, 20 May 2012 23:39:38 +0000 (16:39 -0700)
committerepriestley <git@epriestley.com>
Sun, 20 May 2012 23:39:38 +0000 (16:39 -0700)
Summary:
Hive has custom integration which relies on prefilling a bunch of information from JIRA. This is currently broken and accomplished in a roundabout way. Instead, add an event that the integration can listen for. See next diff.

@Girish, I guess you're official Phabricator/Hive support now?

Test Plan: Ran the Hive/JIRA workflows in Git and SVN, see next diff.

Reviewers: Girish, btrahan, ashutoshc

Reviewed By: btrahan

CC: aran
Maniphest Tasks: T1206

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

src/events/constant/type/ArcanistEventType.php
src/workflow/diff/ArcanistDiffWorkflow.php
src/workflow/diff/__init__.php

index e9ce052d756090dea60ed80f22cc90c0bcb9186d..411dbaaf74b120e65dbc34b7d1a7d74824b102d5 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 
 /*
- * Copyright 2011 Facebook, Inc.
+ * Copyright 2012 Facebook, Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -18,6 +18,7 @@
 
 final class ArcanistEventType extends PhutilEventType {
 
-  const TYPE_COMMIT_WILLCOMMITSVN = 'commit.willCommitSVN';
+  const TYPE_COMMIT_WILLCOMMITSVN   = 'commit.willCommitSVN';
+  const TYPE_DIFF_WILLBUILDMESSAGE  = 'diff.willBuildMessage';
 
 }
index d42079b3270b1a735eac5529e939dad85e128ebc..e8600f381cc953bfcba55bcaf386e4911f65cef2 100644 (file)
@@ -1633,20 +1633,22 @@ EOTEXT
   }
 
   private function getDefaultCreateFields() {
-    $empty = array(array(), array(), array());
+    $result = array(array(), array(), array());
 
     if ($this->isRawDiffSource()) {
-      return $empty;
+      return $result;
     }
 
     $repository_api = $this->getRepositoryAPI();
     if ($repository_api instanceof ArcanistGitAPI) {
-      return $this->getGitCreateFields();
+      $result = $this->getGitCreateFields();
     }
 
     // TODO: Load default fields in Mercurial.
 
-    return $empty;
+    $result[0] = $this->dispatchWillBuildEvent($result[0]);
+
+    return $result;
   }
 
   private function getGitCreateFields() {
@@ -2038,4 +2040,16 @@ EOTEXT
       ));
   }
 
+  private function dispatchWillBuildEvent(array $fields) {
+    $event = new PhutilEvent(
+      ArcanistEventType::TYPE_DIFF_WILLBUILDMESSAGE,
+      array(
+        'fields'      => $fields,
+      ));
+
+    PhutilEventEngine::dispatchEvent($event);
+
+    return $event->getValue('fields');
+  }
+
 }
index ec97b7581726744b4774d6c0094552b6a0b8339f..51c69aa19abba9d8c5a2066e86b822f83e94b380 100644 (file)
@@ -8,6 +8,7 @@
 
 phutil_require_module('arcanist', 'difference');
 phutil_require_module('arcanist', 'differential/commitmessage');
+phutil_require_module('arcanist', 'events/constant/type');
 phutil_require_module('arcanist', 'exception/usage');
 phutil_require_module('arcanist', 'exception/usage/userabort');
 phutil_require_module('arcanist', 'parser/commentremover');
@@ -21,6 +22,8 @@ phutil_require_module('arcanist', 'workflow/unit');
 
 phutil_require_module('phutil', 'console');
 phutil_require_module('phutil', 'console/editor');
+phutil_require_module('phutil', 'events/engine');
+phutil_require_module('phutil', 'events/event');
 phutil_require_module('phutil', 'filesystem');
 phutil_require_module('phutil', 'filesystem/filelist');
 phutil_require_module('phutil', 'filesystem/tempfile');