Permalink
Browse files

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
  • Loading branch information...
1 parent d23d2df commit 3e655e7d4c9e252138526e4d308ee738e51bfa9a @epriestley epriestley committed May 20, 2012
View
5 src/events/constant/type/ArcanistEventType.php
@@ -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';
}
View
22 src/workflow/diff/ArcanistDiffWorkflow.php
@@ -1633,20 +1633,22 @@ private function getLocalGitCommitMessages() {
}
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 @@ private function updateDiffProperty($name, $data) {
));
}
+ private function dispatchWillBuildEvent(array $fields) {
+ $event = new PhutilEvent(
+ ArcanistEventType::TYPE_DIFF_WILLBUILDMESSAGE,
+ array(
+ 'fields' => $fields,
+ ));
+
+ PhutilEventEngine::dispatchEvent($event);
+
+ return $event->getValue('fields');
+ }
+
}
View
3 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('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');

0 comments on commit 3e655e7

Please sign in to comment.