]> khamidou — GitHub mirrors - arcanist.git/commitdiff
Allow modification of the svn commit message via an event listener
authorMarek Sapota <mareksapota@fb.com>
Thu, 17 Nov 2011 00:40:09 +0000 (16:40 -0800)
committerMarek Sapota <mareksapota@fb.com>
Thu, 17 Nov 2011 00:40:19 +0000 (16:40 -0800)
Test Plan:
Wrote an event listener modifying the commit message and the message was
successfully changed.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, jungejason, epriestley
Differential Revision: 1103

src/events/constant/type/ArcanistEventType.php
src/workflow/commit/ArcanistCommitWorkflow.php
src/workflow/commit/__init__.php

index ea8abb5c5d58cede4c349c413eba911cb387cd4f..e9ce052d756090dea60ed80f22cc90c0bcb9186d 100644 (file)
@@ -17,4 +17,7 @@
  */
 
 final class ArcanistEventType extends PhutilEventType {
+
+  const TYPE_COMMIT_WILLCOMMITSVN = 'commit.willCommitSVN';
+
 }
index cd4a882987ebd4b85f77cbfabd7d64cac83bab1b..b6413044a8cf1d58528354863bf214ea12d006ec 100644 (file)
@@ -101,6 +101,8 @@ EOTEXT
       }
     }
 
+    $this->revisionID = $revision_id;
+
     $revision = null;
     try {
       $revision = $conduit->callMethodSynchronous(
@@ -139,6 +141,17 @@ EOTEXT
         'edit'        => false,
       ));
 
+    $event = new PhutilEvent(
+      ArcanistEventType::TYPE_COMMIT_WILLCOMMITSVN,
+      array(
+        'message' => $message,
+        'workflow' => $this
+      )
+    );
+    PhutilEventEngine::dispatchEvent($event);
+
+    $message = $event->getValue('message');
+
     if ($this->getArgument('show')) {
       echo $message;
       return 0;
@@ -173,8 +186,6 @@ EOTEXT
       ));
     $mark_workflow->run();
 
-    $this->revisionID = $revision_id;
-
     return $err;
   }
 
index a63499f835f293422661d6ea30cc50ca996cfe45..40166f2236358e55eb7a5e42fbc2afb4ca49c5ad 100644 (file)
@@ -6,12 +6,15 @@
 
 
 
+phutil_require_module('arcanist', 'events/constant/type');
 phutil_require_module('arcanist', 'exception/usage');
 phutil_require_module('arcanist', 'exception/usage/userabort');
 phutil_require_module('arcanist', 'repository/api/base');
 phutil_require_module('arcanist', 'workflow/base');
 
 phutil_require_module('phutil', 'console');
+phutil_require_module('phutil', 'events/engine');
+phutil_require_module('phutil', 'events/event');
 phutil_require_module('phutil', 'filesystem');
 phutil_require_module('phutil', 'future/exec');
 phutil_require_module('phutil', 'utils');