diff --git a/src/applications/differential/parser/changeset/DifferentialChangesetParser.php b/src/applications/differential/parser/changeset/DifferentialChangesetParser.php index e3c605dc9c..4682350451 100644 --- a/src/applications/differential/parser/changeset/DifferentialChangesetParser.php +++ b/src/applications/differential/parser/changeset/DifferentialChangesetParser.php @@ -540,7 +540,18 @@ class DifferentialChangesetParser { ipull($this->intra, 1), $new_corpus); - $generated = (strpos($new_corpus_block, '@'.'generated') !== false); + $generated_guess = (strpos($new_corpus_block, '@'.'generated') !== false); + + $event = new PhabricatorEvent( + PhabricatorEventType::TYPE_DIFFERENTIAL_WILLMARKGENERATED, + array( + 'corpus' => $new_corpus_block, + 'is_generated' => $generated_guess + ) + ); + PhutilEventEngine::dispatchEvent($event); + + $generated = $event->getValue('is_generated'); $this->specialAttributes[self::ATTR_GENERATED] = $generated; } diff --git a/src/applications/differential/parser/changeset/__init__.php b/src/applications/differential/parser/changeset/__init__.php index eb424211e9..26ebee053e 100644 --- a/src/applications/differential/parser/changeset/__init__.php +++ b/src/applications/differential/parser/changeset/__init__.php @@ -15,10 +15,13 @@ phutil_require_module('phabricator', 'applications/differential/view/inlinecomme phutil_require_module('phabricator', 'applications/files/uri'); phutil_require_module('phabricator', 'applications/markup/syntax'); phutil_require_module('phabricator', 'infrastructure/diff/engine'); +phutil_require_module('phabricator', 'infrastructure/events/constant/type'); +phutil_require_module('phabricator', 'infrastructure/events/event'); phutil_require_module('phabricator', 'infrastructure/javelin/markup'); phutil_require_module('phabricator', 'storage/queryfx'); phutil_require_module('phutil', 'error'); +phutil_require_module('phutil', 'events/engine'); phutil_require_module('phutil', 'future'); phutil_require_module('phutil', 'markup'); phutil_require_module('phutil', 'utils'); diff --git a/src/docs/userguide/events.diviner b/src/docs/userguide/events.diviner index c9894c8a29..339c5f492e 100644 --- a/src/docs/userguide/events.diviner +++ b/src/docs/userguide/events.diviner @@ -28,7 +28,16 @@ or alter the edit. Data available on this event: == PhabricatorEventType::TYPE_DIFFERENTIAL_WILLSENDMAIL == -This event is dispatche before Differential sends an email, and allows you to +This event is dispatched before Differential sends an email, and allows you to edit the message that will be sent. Data available on this event: - ##mail## The {@class:PhabricatorMetaMTAMail} being edited. + +== PhabricatorEventType::TYPE_DIFFERENTIAL_WILLMARKGENERATED == + +This event is dispatched before Differential decides if a file is generated (and +doesn't need to be reviewed) or not. Data available on this event: + + - ##corpus## Body of the file. + - ##is_generated## Boolean indicating if this file should be treated as + generated. diff --git a/src/infrastructure/events/constant/type/PhabricatorEventType.php b/src/infrastructure/events/constant/type/PhabricatorEventType.php index deaec635f6..9d13a84ea2 100644 --- a/src/infrastructure/events/constant/type/PhabricatorEventType.php +++ b/src/infrastructure/events/constant/type/PhabricatorEventType.php @@ -20,5 +20,6 @@ final class PhabricatorEventType extends PhutilEventType { const TYPE_MANIPHEST_WILLEDITTASK = 'maniphest.willEditTask'; const TYPE_DIFFERENTIAL_WILLSENDMAIL = 'differential.willSendMail'; + const TYPE_DIFFERENTIAL_WILLMARKGENERATED = 'differential.willMarkGenerated'; }