mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-19 13:22:42 +01:00
Add "Is merge commit?" to commit fields in Herald
Summary: Fixes T5788. We already have this as a pre-commit field, add it as a post-commit field too. Test Plan: Ran this rule on a merge commit. Also ran it on a non-merge commit. Both got the correct value. Reviewers: avivey, chad Reviewed By: avivey, chad Subscribers: avivey Maniphest Tasks: T5788 Differential Revision: https://secure.phabricator.com/D14685
This commit is contained in:
parent
bc331f0fbf
commit
2353121dee
3 changed files with 49 additions and 10 deletions
|
@ -550,6 +550,7 @@ phutil_register_library_map(array(
|
||||||
'DiffusionCommitHeraldFieldGroup' => 'applications/diffusion/herald/DiffusionCommitHeraldFieldGroup.php',
|
'DiffusionCommitHeraldFieldGroup' => 'applications/diffusion/herald/DiffusionCommitHeraldFieldGroup.php',
|
||||||
'DiffusionCommitHookEngine' => 'applications/diffusion/engine/DiffusionCommitHookEngine.php',
|
'DiffusionCommitHookEngine' => 'applications/diffusion/engine/DiffusionCommitHookEngine.php',
|
||||||
'DiffusionCommitHookRejectException' => 'applications/diffusion/exception/DiffusionCommitHookRejectException.php',
|
'DiffusionCommitHookRejectException' => 'applications/diffusion/exception/DiffusionCommitHookRejectException.php',
|
||||||
|
'DiffusionCommitMergeHeraldField' => 'applications/diffusion/herald/DiffusionCommitMergeHeraldField.php',
|
||||||
'DiffusionCommitMessageHeraldField' => 'applications/diffusion/herald/DiffusionCommitMessageHeraldField.php',
|
'DiffusionCommitMessageHeraldField' => 'applications/diffusion/herald/DiffusionCommitMessageHeraldField.php',
|
||||||
'DiffusionCommitPackageAuditHeraldField' => 'applications/diffusion/herald/DiffusionCommitPackageAuditHeraldField.php',
|
'DiffusionCommitPackageAuditHeraldField' => 'applications/diffusion/herald/DiffusionCommitPackageAuditHeraldField.php',
|
||||||
'DiffusionCommitPackageHeraldField' => 'applications/diffusion/herald/DiffusionCommitPackageHeraldField.php',
|
'DiffusionCommitPackageHeraldField' => 'applications/diffusion/herald/DiffusionCommitPackageHeraldField.php',
|
||||||
|
@ -4412,6 +4413,7 @@ phutil_register_library_map(array(
|
||||||
'DiffusionCommitHeraldFieldGroup' => 'HeraldFieldGroup',
|
'DiffusionCommitHeraldFieldGroup' => 'HeraldFieldGroup',
|
||||||
'DiffusionCommitHookEngine' => 'Phobject',
|
'DiffusionCommitHookEngine' => 'Phobject',
|
||||||
'DiffusionCommitHookRejectException' => 'Exception',
|
'DiffusionCommitHookRejectException' => 'Exception',
|
||||||
|
'DiffusionCommitMergeHeraldField' => 'DiffusionCommitHeraldField',
|
||||||
'DiffusionCommitMessageHeraldField' => 'DiffusionCommitHeraldField',
|
'DiffusionCommitMessageHeraldField' => 'DiffusionCommitHeraldField',
|
||||||
'DiffusionCommitPackageAuditHeraldField' => 'DiffusionCommitHeraldField',
|
'DiffusionCommitPackageAuditHeraldField' => 'DiffusionCommitHeraldField',
|
||||||
'DiffusionCommitPackageHeraldField' => 'DiffusionCommitHeraldField',
|
'DiffusionCommitPackageHeraldField' => 'DiffusionCommitHeraldField',
|
||||||
|
|
|
@ -0,0 +1,20 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
final class DiffusionCommitMergeHeraldField
|
||||||
|
extends DiffusionCommitHeraldField {
|
||||||
|
|
||||||
|
const FIELDCONST = 'diffusion.commit.merge';
|
||||||
|
|
||||||
|
public function getHeraldFieldName() {
|
||||||
|
return pht('Is merge commit');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getHeraldFieldValue($object) {
|
||||||
|
return $this->getAdapter()->loadIsMergeCommit();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function getHeraldFieldStandardType() {
|
||||||
|
return HeraldField::STANDARD_BOOL;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -209,18 +209,9 @@ final class HeraldCommitAdapter
|
||||||
}
|
}
|
||||||
|
|
||||||
private function loadCommitDiff() {
|
private function loadCommitDiff() {
|
||||||
$drequest = DiffusionRequest::newFromDictionary(
|
|
||||||
array(
|
|
||||||
'user' => PhabricatorUser::getOmnipotentUser(),
|
|
||||||
'repository' => $this->repository,
|
|
||||||
'commit' => $this->commit->getCommitIdentifier(),
|
|
||||||
));
|
|
||||||
|
|
||||||
$byte_limit = self::getEnormousByteLimit();
|
$byte_limit = self::getEnormousByteLimit();
|
||||||
|
|
||||||
$raw = DiffusionQuery::callConduitWithDiffusionRequest(
|
$raw = $this->callConduit(
|
||||||
PhabricatorUser::getOmnipotentUser(),
|
|
||||||
$drequest,
|
|
||||||
'diffusion.rawdiffquery',
|
'diffusion.rawdiffquery',
|
||||||
array(
|
array(
|
||||||
'commit' => $this->commit->getCommitIdentifier(),
|
'commit' => $this->commit->getCommitIdentifier(),
|
||||||
|
@ -296,6 +287,32 @@ final class HeraldCommitAdapter
|
||||||
return $result;
|
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 )------------------------------ */
|
/* -( HarbormasterBuildableAdapterInterface )------------------------------ */
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue