From 3e655e7d4c9e252138526e4d308ee738e51bfa9a Mon Sep 17 00:00:00 2001 From: epriestley Date: Sun, 20 May 2012 16:39:38 -0700 Subject: [PATCH] Dispatch a "diff.willBuildMessage" event from Arcanist 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 --- .../constant/type/ArcanistEventType.php | 5 +++-- src/workflow/diff/ArcanistDiffWorkflow.php | 22 +++++++++++++++---- src/workflow/diff/__init__.php | 3 +++ 3 files changed, 24 insertions(+), 6 deletions(-) diff --git a/src/events/constant/type/ArcanistEventType.php b/src/events/constant/type/ArcanistEventType.php index e9ce052d..411dbaaf 100644 --- a/src/events/constant/type/ArcanistEventType.php +++ b/src/events/constant/type/ArcanistEventType.php @@ -1,7 +1,7 @@ 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'); + } + } diff --git a/src/workflow/diff/__init__.php b/src/workflow/diff/__init__.php index ec97b758..51c69aa1 100644 --- a/src/workflow/diff/__init__.php +++ b/src/workflow/diff/__init__.php @@ -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');