Skip to content

Commit

Permalink
Dispatch a "diff.willBuildMessage" event from Arcanist
Browse files Browse the repository at this point in the history
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
epriestley committed May 20, 2012
1 parent d23d2df commit 3e655e7
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 6 deletions.
5 changes: 3 additions & 2 deletions src/events/constant/type/ArcanistEventType.php
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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';

}
22 changes: 18 additions & 4 deletions src/workflow/diff/ArcanistDiffWorkflow.php
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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');
}

}
3 changes: 3 additions & 0 deletions src/workflow/diff/__init__.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -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');
Expand Down

0 comments on commit 3e655e7

Please sign in to comment.