Changeset View
Changeset View
Standalone View
Standalone View
src/applications/herald/adapter/HeraldCommitAdapter.php
<?php | <?php | ||||
final class HeraldCommitAdapter extends HeraldAdapter { | final class HeraldCommitAdapter extends HeraldAdapter { | ||||
const FIELD_NEED_AUDIT_FOR_PACKAGE = 'need-audit-for-package'; | const FIELD_NEED_AUDIT_FOR_PACKAGE = 'need-audit-for-package'; | ||||
const FIELD_REPOSITORY_AUTOCLOSE_BRANCH = 'repository-autoclose-branch'; | const FIELD_REPOSITORY_AUTOCLOSE_BRANCH = 'repository-autoclose-branch'; | ||||
protected $diff; | protected $diff; | ||||
protected $revision; | protected $revision; | ||||
protected $repository; | protected $repository; | ||||
protected $commit; | protected $commit; | ||||
protected $commitData; | protected $commitData; | ||||
private $commitDiff; | private $commitDiff; | ||||
protected $addCCPHIDs = array(); | |||||
protected $auditMap = array(); | protected $auditMap = array(); | ||||
protected $buildPlans = array(); | protected $buildPlans = array(); | ||||
protected $affectedPaths; | protected $affectedPaths; | ||||
protected $affectedRevision; | protected $affectedRevision; | ||||
protected $affectedPackages; | protected $affectedPackages; | ||||
protected $auditNeededPackages; | protected $auditNeededPackages; | ||||
▲ Show 20 Lines • Show All 111 Lines • ▼ Show 20 Lines | final class HeraldCommitAdapter extends HeraldAdapter { | ||||
public function getActions($rule_type) { | public function getActions($rule_type) { | ||||
switch ($rule_type) { | switch ($rule_type) { | ||||
case HeraldRuleTypeConfig::RULE_TYPE_GLOBAL: | case HeraldRuleTypeConfig::RULE_TYPE_GLOBAL: | ||||
case HeraldRuleTypeConfig::RULE_TYPE_OBJECT: | case HeraldRuleTypeConfig::RULE_TYPE_OBJECT: | ||||
return array_merge( | return array_merge( | ||||
array( | array( | ||||
self::ACTION_ADD_CC, | self::ACTION_ADD_CC, | ||||
self::ACTION_REMOVE_CC, | |||||
self::ACTION_EMAIL, | self::ACTION_EMAIL, | ||||
self::ACTION_AUDIT, | self::ACTION_AUDIT, | ||||
self::ACTION_APPLY_BUILD_PLANS, | self::ACTION_APPLY_BUILD_PLANS, | ||||
self::ACTION_NOTHING, | self::ACTION_NOTHING, | ||||
), | ), | ||||
parent::getActions($rule_type)); | parent::getActions($rule_type)); | ||||
case HeraldRuleTypeConfig::RULE_TYPE_PERSONAL: | case HeraldRuleTypeConfig::RULE_TYPE_PERSONAL: | ||||
return array_merge( | return array_merge( | ||||
array( | array( | ||||
self::ACTION_ADD_CC, | self::ACTION_ADD_CC, | ||||
self::ACTION_REMOVE_CC, | |||||
self::ACTION_EMAIL, | self::ACTION_EMAIL, | ||||
self::ACTION_FLAG, | self::ACTION_FLAG, | ||||
self::ACTION_AUDIT, | self::ACTION_AUDIT, | ||||
self::ACTION_NOTHING, | self::ACTION_NOTHING, | ||||
), | ), | ||||
parent::getActions($rule_type)); | parent::getActions($rule_type)); | ||||
} | } | ||||
} | } | ||||
▲ Show 20 Lines • Show All 53 Lines • ▼ Show 20 Lines | public function setCommit(PhabricatorRepositoryCommit $commit) { | ||||
return $this; | return $this; | ||||
} | } | ||||
public function getPHID() { | public function getPHID() { | ||||
return $this->commit->getPHID(); | return $this->commit->getPHID(); | ||||
} | } | ||||
public function getAddCCMap() { | |||||
return $this->addCCPHIDs; | |||||
} | |||||
public function getAuditMap() { | public function getAuditMap() { | ||||
return $this->auditMap; | return $this->auditMap; | ||||
} | } | ||||
public function getBuildPlans() { | public function getBuildPlans() { | ||||
return $this->buildPlans; | return $this->buildPlans; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 251 Lines • ▼ Show 20 Lines | final class HeraldCommitAdapter extends HeraldAdapter { | ||||
public function applyHeraldEffects(array $effects) { | public function applyHeraldEffects(array $effects) { | ||||
assert_instances_of($effects, 'HeraldEffect'); | assert_instances_of($effects, 'HeraldEffect'); | ||||
$result = array(); | $result = array(); | ||||
foreach ($effects as $effect) { | foreach ($effects as $effect) { | ||||
$action = $effect->getAction(); | $action = $effect->getAction(); | ||||
switch ($action) { | switch ($action) { | ||||
case self::ACTION_ADD_CC: | |||||
foreach ($effect->getTarget() as $phid) { | |||||
if (empty($this->addCCPHIDs[$phid])) { | |||||
$this->addCCPHIDs[$phid] = array(); | |||||
} | |||||
$this->addCCPHIDs[$phid][] = $effect->getRule()->getID(); | |||||
} | |||||
$result[] = new HeraldApplyTranscript( | |||||
$effect, | |||||
true, | |||||
pht('Added address to CC.')); | |||||
break; | |||||
case self::ACTION_AUDIT: | case self::ACTION_AUDIT: | ||||
foreach ($effect->getTarget() as $phid) { | foreach ($effect->getTarget() as $phid) { | ||||
if (empty($this->auditMap[$phid])) { | if (empty($this->auditMap[$phid])) { | ||||
$this->auditMap[$phid] = array(); | $this->auditMap[$phid] = array(); | ||||
} | } | ||||
$this->auditMap[$phid][] = $effect->getRule()->getID(); | $this->auditMap[$phid][] = $effect->getRule()->getID(); | ||||
} | } | ||||
$result[] = new HeraldApplyTranscript( | $result[] = new HeraldApplyTranscript( | ||||
Show All 22 Lines |