From 53c64f64b0169a7d9076f265b8c0a4953a1b9d0b Mon Sep 17 00:00:00 2001 From: Marek Sapota Date: Thu, 10 Nov 2011 13:47:45 -0800 Subject: [PATCH] Add events framework to Arcanist Test Plan: Added a test event listener, added an event dispatch in diff workflow, run the workflow, the listener was called. Reviewers: epriestley Reviewed By: epriestley CC: aran, jungejason, epriestley Differential Revision: 1102 --- scripts/arcanist.php | 7 +++++++ src/__phutil_library_map__.php | 2 ++ .../constant/type/ArcanistEventType.php | 20 +++++++++++++++++++ src/events/constant/type/__init__.php | 12 +++++++++++ 4 files changed, 41 insertions(+) create mode 100644 src/events/constant/type/ArcanistEventType.php create mode 100644 src/events/constant/type/__init__.php diff --git a/scripts/arcanist.php b/scripts/arcanist.php index f4ecf925..f900ce50 100755 --- a/scripts/arcanist.php +++ b/scripts/arcanist.php @@ -252,6 +252,13 @@ try { $workflow->setRepositoryAPI($repository_api); } + $listeners = $working_copy->getConfig('events.listeners'); + if ($listeners) { + foreach ($listeners as $listener) { + id(new $listener())->register(); + } + } + $config->willRunWorkflow($command, $workflow); $workflow->willRunWorkflow(); $err = $workflow->run(); diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index d4ef91b7..bf97f652 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -35,6 +35,7 @@ phutil_register_library_map(array( 'ArcanistDifferentialCommitMessageParserException' => 'differential/commitmessage', 'ArcanistDifferentialRevisionRef' => 'differential/revision', 'ArcanistDownloadWorkflow' => 'workflow/download', + 'ArcanistEventType' => 'events/constant/type', 'ArcanistExportWorkflow' => 'workflow/export', 'ArcanistFilenameLinter' => 'lint/linter/filename', 'ArcanistGeneratedLinter' => 'lint/linter/generated', @@ -114,6 +115,7 @@ phutil_register_library_map(array( 'ArcanistDiffUtilsTestCase' => 'ArcanistPhutilTestCase', 'ArcanistDiffWorkflow' => 'ArcanistBaseWorkflow', 'ArcanistDownloadWorkflow' => 'ArcanistBaseWorkflow', + 'ArcanistEventType' => 'PhutilEventType', 'ArcanistExportWorkflow' => 'ArcanistBaseWorkflow', 'ArcanistFilenameLinter' => 'ArcanistLinter', 'ArcanistGeneratedLinter' => 'ArcanistLinter', diff --git a/src/events/constant/type/ArcanistEventType.php b/src/events/constant/type/ArcanistEventType.php new file mode 100644 index 00000000..ea8abb5c --- /dev/null +++ b/src/events/constant/type/ArcanistEventType.php @@ -0,0 +1,20 @@ +