1
0
Fork 0
mirror of https://we.phorge.it/source/arcanist.git synced 2024-11-26 00:32:41 +01:00

Add a willCreateRevision event

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
This commit is contained in:
epriestley 2012-08-30 12:28:35 -07:00
parent 4a786f48de
commit d79664a30d
2 changed files with 18 additions and 1 deletions

View file

@ -19,8 +19,10 @@
final class ArcanistEventType extends PhutilEventType { final class ArcanistEventType extends PhutilEventType {
const TYPE_COMMIT_WILLCOMMITSVN = 'commit.willCommitSVN'; const TYPE_COMMIT_WILLCOMMITSVN = 'commit.willCommitSVN';
const TYPE_DIFF_WILLBUILDMESSAGE = 'diff.willBuildMessage'; const TYPE_DIFF_WILLBUILDMESSAGE = 'diff.willBuildMessage';
const TYPE_DIFF_DIDBUILDMESSAGE = 'diff.didBuildMessage'; const TYPE_DIFF_DIDBUILDMESSAGE = 'diff.didBuildMessage';
const TYPE_DIFF_WASCREATED = 'diff.wasCreated'; const TYPE_DIFF_WASCREATED = 'diff.wasCreated';
const TYPE_REVISION_WILLCREATEREVISION = 'revision.willCreateRevision';
} }

View file

@ -479,6 +479,9 @@ EOTEXT
echo "Updated an existing Differential revision:\n"; echo "Updated an existing Differential revision:\n";
} else { } else {
$revision['user'] = $this->getUserPHID(); $revision['user'] = $this->getUserPHID();
$revision = $this->dispatchWillCreateRevisionEvent($revision);
$future = $conduit->callMethod( $future = $conduit->callMethod(
'differential.createrevision', 'differential.createrevision',
$revision); $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) { private function dispatchWillBuildEvent(array $fields) {
$event = new PhutilEvent( $event = new PhutilEvent(
ArcanistEventType::TYPE_DIFF_WILLBUILDMESSAGE, ArcanistEventType::TYPE_DIFF_WILLBUILDMESSAGE,
array( array(
'fields' => $fields, 'fields' => $fields,
)); ));
PhutilEventEngine::dispatchEvent($event); PhutilEventEngine::dispatchEvent($event);