diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index 083ef473fa..a4d8a6b7a8 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -550,6 +550,7 @@ phutil_register_library_map(array( 'DiffusionCommitHeraldFieldGroup' => 'applications/diffusion/herald/DiffusionCommitHeraldFieldGroup.php', 'DiffusionCommitHookEngine' => 'applications/diffusion/engine/DiffusionCommitHookEngine.php', 'DiffusionCommitHookRejectException' => 'applications/diffusion/exception/DiffusionCommitHookRejectException.php', + 'DiffusionCommitMergeHeraldField' => 'applications/diffusion/herald/DiffusionCommitMergeHeraldField.php', 'DiffusionCommitMessageHeraldField' => 'applications/diffusion/herald/DiffusionCommitMessageHeraldField.php', 'DiffusionCommitPackageAuditHeraldField' => 'applications/diffusion/herald/DiffusionCommitPackageAuditHeraldField.php', 'DiffusionCommitPackageHeraldField' => 'applications/diffusion/herald/DiffusionCommitPackageHeraldField.php', @@ -4412,6 +4413,7 @@ phutil_register_library_map(array( 'DiffusionCommitHeraldFieldGroup' => 'HeraldFieldGroup', 'DiffusionCommitHookEngine' => 'Phobject', 'DiffusionCommitHookRejectException' => 'Exception', + 'DiffusionCommitMergeHeraldField' => 'DiffusionCommitHeraldField', 'DiffusionCommitMessageHeraldField' => 'DiffusionCommitHeraldField', 'DiffusionCommitPackageAuditHeraldField' => 'DiffusionCommitHeraldField', 'DiffusionCommitPackageHeraldField' => 'DiffusionCommitHeraldField', diff --git a/src/applications/diffusion/herald/DiffusionCommitMergeHeraldField.php b/src/applications/diffusion/herald/DiffusionCommitMergeHeraldField.php new file mode 100644 index 0000000000..9fcfc985b0 --- /dev/null +++ b/src/applications/diffusion/herald/DiffusionCommitMergeHeraldField.php @@ -0,0 +1,20 @@ +getAdapter()->loadIsMergeCommit(); + } + + protected function getHeraldFieldStandardType() { + return HeraldField::STANDARD_BOOL; + } + +} diff --git a/src/applications/diffusion/herald/HeraldCommitAdapter.php b/src/applications/diffusion/herald/HeraldCommitAdapter.php index 6530b72e6f..9baac6f2ad 100644 --- a/src/applications/diffusion/herald/HeraldCommitAdapter.php +++ b/src/applications/diffusion/herald/HeraldCommitAdapter.php @@ -209,18 +209,9 @@ final class HeraldCommitAdapter } private function loadCommitDiff() { - $drequest = DiffusionRequest::newFromDictionary( - array( - 'user' => PhabricatorUser::getOmnipotentUser(), - 'repository' => $this->repository, - 'commit' => $this->commit->getCommitIdentifier(), - )); - $byte_limit = self::getEnormousByteLimit(); - $raw = DiffusionQuery::callConduitWithDiffusionRequest( - PhabricatorUser::getOmnipotentUser(), - $drequest, + $raw = $this->callConduit( 'diffusion.rawdiffquery', array( 'commit' => $this->commit->getCommitIdentifier(), @@ -296,6 +287,32 @@ final class HeraldCommitAdapter return $result; } + public function loadIsMergeCommit() { + $parents = $this->callConduit( + 'diffusion.commitparentsquery', + array( + 'commit' => $this->getObject()->getCommitIdentifier(), + )); + + return (count($parents) > 1); + } + + private function callConduit($method, array $params) { + $viewer = PhabricatorUser::getOmnipotentUser(); + + $drequest = DiffusionRequest::newFromDictionary( + array( + 'user' => $viewer, + 'repository' => $this->repository, + 'commit' => $this->commit->getCommitIdentifier(), + )); + + return DiffusionQuery::callConduitWithDiffusionRequest( + $viewer, + $drequest, + $method, + $params); + } /* -( HarbormasterBuildableAdapterInterface )------------------------------ */