repo stringlengths 7 63 | file_url stringlengths 81 284 | file_path stringlengths 5 200 | content stringlengths 0 32.8k | language stringclasses 1
value | license stringclasses 7
values | commit_sha stringlengths 40 40 | retrieved_at stringdate 2026-01-04 15:02:33 2026-01-05 05:24:06 | truncated bool 2
classes |
|---|---|---|---|---|---|---|---|---|
phacility/phabricator | https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/diffusion/herald/DiffusionPreCommitContentRevisionSubscribersHeraldField.php | src/applications/diffusion/herald/DiffusionPreCommitContentRevisionSubscribersHeraldField.php | <?php
final class DiffusionPreCommitContentRevisionSubscribersHeraldField
extends DiffusionPreCommitContentHeraldField {
const FIELDCONST = 'diffusion.pre.content.revision.subscribers';
public function getHeraldFieldName() {
return pht('Differential subscribers');
}
public function getFieldGroupKey() {
return HeraldRelatedFieldGroup::FIELDGROUPKEY;
}
public function getHeraldFieldValue($object) {
$revision = $this->getAdapter()->getRevision();
if (!$revision) {
return array();
}
$phid = $revision->getPHID();
return PhabricatorSubscribersQuery::loadSubscribersForPHID($phid);
}
protected function getHeraldFieldStandardType() {
return self::STANDARD_PHID_LIST;
}
protected function getDatasource() {
return new PhabricatorProjectOrUserDatasource();
}
}
| php | Apache-2.0 | 5720a38cfe95b00ca4be5016dd0d2f3195f4fa04 | 2026-01-04T15:03:23.651835Z | false |
phacility/phabricator | https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/diffusion/herald/DiffusionPreCommitContentBranchesHeraldField.php | src/applications/diffusion/herald/DiffusionPreCommitContentBranchesHeraldField.php | <?php
final class DiffusionPreCommitContentBranchesHeraldField
extends DiffusionPreCommitContentHeraldField {
const FIELDCONST = 'diffusion.pre.commit.branches';
public function getHeraldFieldName() {
return pht('Branches');
}
public function getHeraldFieldValue($object) {
return $this->getAdapter()->getBranches();
}
protected function getHeraldFieldStandardType() {
return self::STANDARD_TEXT_LIST;
}
}
| php | Apache-2.0 | 5720a38cfe95b00ca4be5016dd0d2f3195f4fa04 | 2026-01-04T15:03:23.651835Z | false |
phacility/phabricator | https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/diffusion/herald/DiffusionCommitHeraldFieldGroup.php | src/applications/diffusion/herald/DiffusionCommitHeraldFieldGroup.php | <?php
final class DiffusionCommitHeraldFieldGroup extends HeraldFieldGroup {
const FIELDGROUPKEY = 'diffusion.commit';
public function getGroupLabel() {
return pht('Commit Fields');
}
protected function getGroupOrder() {
return 1000;
}
}
| php | Apache-2.0 | 5720a38cfe95b00ca4be5016dd0d2f3195f4fa04 | 2026-01-04T15:03:23.651835Z | false |
phacility/phabricator | https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/diffusion/herald/DiffusionPreCommitRefRepositoryHeraldField.php | src/applications/diffusion/herald/DiffusionPreCommitRefRepositoryHeraldField.php | <?php
final class DiffusionPreCommitRefRepositoryHeraldField
extends DiffusionPreCommitRefHeraldField {
const FIELDCONST = 'diffusion.pre.ref.repository';
public function getHeraldFieldName() {
return pht('Repository');
}
public function getHeraldFieldValue($object) {
return $this->getAdapter()->getHookEngine()->getRepository()->getPHID();
}
protected function getHeraldFieldStandardType() {
return HeraldField::STANDARD_PHID;
}
protected function getDatasource() {
return new DiffusionRepositoryDatasource();
}
}
| php | Apache-2.0 | 5720a38cfe95b00ca4be5016dd0d2f3195f4fa04 | 2026-01-04T15:03:23.651835Z | false |
phacility/phabricator | https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/diffusion/herald/DiffusionPreCommitContentMessageHeraldField.php | src/applications/diffusion/herald/DiffusionPreCommitContentMessageHeraldField.php | <?php
final class DiffusionPreCommitContentMessageHeraldField
extends DiffusionPreCommitContentHeraldField {
const FIELDCONST = 'diffusion.pre.commit.message';
public function getHeraldFieldName() {
return pht('Commit message');
}
public function getHeraldFieldValue($object) {
return $this->getAdapter()->getCommitRef()->getMessage();
}
protected function getHeraldFieldStandardType() {
return self::STANDARD_TEXT;
}
}
| php | Apache-2.0 | 5720a38cfe95b00ca4be5016dd0d2f3195f4fa04 | 2026-01-04T15:03:23.651835Z | false |
phacility/phabricator | https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/diffusion/herald/DiffusionPreCommitContentCommitterPackagesHeraldField.php | src/applications/diffusion/herald/DiffusionPreCommitContentCommitterPackagesHeraldField.php | <?php
final class DiffusionPreCommitContentCommitterPackagesHeraldField
extends DiffusionPreCommitContentHeraldField {
const FIELDCONST = 'diffusion.pre.commit.committer.packages';
public function getHeraldFieldName() {
return pht("Committer's packages");
}
public function getHeraldFieldValue($object) {
$adapter = $this->getAdapter();
$viewer = $adapter->getViewer();
$committer_phid = $adapter->getCommitterPHID();
if (!$committer_phid) {
return array();
}
$packages = id(new PhabricatorOwnersPackageQuery())
->setViewer($viewer)
->withAuthorityPHIDs(array($committer_phid))
->execute();
return mpull($packages, 'getPHID');
}
protected function getHeraldFieldStandardType() {
return self::STANDARD_PHID_LIST;
}
protected function getDatasource() {
return new PhabricatorOwnersPackageDatasource();
}
}
| php | Apache-2.0 | 5720a38cfe95b00ca4be5016dd0d2f3195f4fa04 | 2026-01-04T15:03:23.651835Z | false |
phacility/phabricator | https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/diffusion/herald/DiffusionPreCommitContentAuthorRawHeraldField.php | src/applications/diffusion/herald/DiffusionPreCommitContentAuthorRawHeraldField.php | <?php
final class DiffusionPreCommitContentAuthorRawHeraldField
extends DiffusionPreCommitContentHeraldField {
const FIELDCONST = 'diffusion.pre.commit.author.raw';
public function getHeraldFieldName() {
return pht('Raw Author');
}
public function getHeraldFieldValue($object) {
return $this->getAdapter()->getAuthorRaw();
}
protected function getHeraldFieldStandardType() {
return self::STANDARD_TEXT;
}
}
| php | Apache-2.0 | 5720a38cfe95b00ca4be5016dd0d2f3195f4fa04 | 2026-01-04T15:03:23.651835Z | false |
phacility/phabricator | https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/diffusion/herald/DiffusionPreCommitContentWrongBuildsHeraldField.php | src/applications/diffusion/herald/DiffusionPreCommitContentWrongBuildsHeraldField.php | <?php
final class DiffusionPreCommitContentWrongBuildsHeraldField
extends DiffusionPreCommitContentHeraldField {
const FIELDCONST = 'diffusion.pre.content.builds.wrong';
public function getHeraldFieldName() {
return pht('Revision has build warning');
}
public function getFieldGroupKey() {
return HeraldRelatedFieldGroup::FIELDGROUPKEY;
}
public function getHeraldFieldValue($object) {
$adapter = $this->getAdapter();
$viewer = $adapter->getViewer();
$revision = $adapter->getRevision();
if (!$revision) {
return false;
}
if ($revision->isPublished()) {
$wrong_builds = DifferentialRevision::PROPERTY_WRONG_BUILDS;
return !$revision->getProperty($wrong_builds, false);
}
// Reload the revision to pick up active diffs.
$revision = id(new DifferentialRevisionQuery())
->setViewer($viewer)
->withPHIDs(array($revision->getPHID()))
->needActiveDiffs(true)
->executeOne();
$concerning = DifferentialDiffExtractionEngine::loadConcerningBuilds(
$viewer,
$revision,
$strict = true);
return (bool)$concerning;
}
protected function getHeraldFieldStandardType() {
return self::STANDARD_BOOL;
}
}
| php | Apache-2.0 | 5720a38cfe95b00ca4be5016dd0d2f3195f4fa04 | 2026-01-04T15:03:23.651835Z | false |
phacility/phabricator | https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/diffusion/herald/DiffusionChangeHeraldFieldGroup.php | src/applications/diffusion/herald/DiffusionChangeHeraldFieldGroup.php | <?php
final class DiffusionChangeHeraldFieldGroup extends HeraldFieldGroup {
const FIELDGROUPKEY = 'diffusion.change';
public function getGroupLabel() {
return pht('Change Details');
}
protected function getGroupOrder() {
return 1500;
}
}
| php | Apache-2.0 | 5720a38cfe95b00ca4be5016dd0d2f3195f4fa04 | 2026-01-04T15:03:23.651835Z | false |
phacility/phabricator | https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/diffusion/herald/DiffusionCommitWrongBuildsHeraldField.php | src/applications/diffusion/herald/DiffusionCommitWrongBuildsHeraldField.php | <?php
final class DiffusionCommitWrongBuildsHeraldField
extends DiffusionCommitHeraldField {
const FIELDCONST = 'diffusion.commit.builds.wrong';
public function getHeraldFieldName() {
return pht('Revision has build warning');
}
public function getFieldGroupKey() {
return HeraldRelatedFieldGroup::FIELDGROUPKEY;
}
public function getHeraldFieldValue($object) {
$adapter = $this->getAdapter();
$viewer = $adapter->getViewer();
$revision = $adapter->loadDifferentialRevision();
if (!$revision) {
return false;
}
if ($revision->isPublished()) {
$wrong_builds = DifferentialRevision::PROPERTY_WRONG_BUILDS;
return !$revision->getProperty($wrong_builds, false);
}
// Reload the revision to pick up active diffs.
$revision = id(new DifferentialRevisionQuery())
->setViewer($viewer)
->withPHIDs(array($revision->getPHID()))
->needActiveDiffs(true)
->executeOne();
$concerning = DifferentialDiffExtractionEngine::loadConcerningBuilds(
$viewer,
$revision,
$strict = false);
return (bool)$concerning;
}
protected function getHeraldFieldStandardType() {
return self::STANDARD_BOOL;
}
}
| php | Apache-2.0 | 5720a38cfe95b00ca4be5016dd0d2f3195f4fa04 | 2026-01-04T15:03:23.651835Z | false |
phacility/phabricator | https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/diffusion/herald/DiffusionBlockHeraldAction.php | src/applications/diffusion/herald/DiffusionBlockHeraldAction.php | <?php
final class DiffusionBlockHeraldAction
extends HeraldAction {
const ACTIONCONST = 'diffusion.block';
const DO_BLOCK = 'do.block';
public function getHeraldActionName() {
return pht('Block push with message');
}
public function getActionGroupKey() {
return HeraldApplicationActionGroup::ACTIONGROUPKEY;
}
public function supportsObject($object) {
return ($object instanceof PhabricatorRepositoryPushLog);
}
public function supportsRuleType($rule_type) {
return ($rule_type != HeraldRuleTypeConfig::RULE_TYPE_PERSONAL);
}
public function applyEffect($object, HeraldEffect $effect) {
// This rule intentionally has no direct effect: the caller handles it
// after executing Herald.
$this->logEffect(self::DO_BLOCK);
}
public function getHeraldActionStandardType() {
return self::STANDARD_TEXT;
}
public function renderActionDescription($value) {
return pht('Block push with message: %s', $value);
}
protected function getActionEffectMap() {
return array(
self::DO_BLOCK => array(
'icon' => 'fa-stop',
'color' => 'red',
'name' => pht('Blocked Push'),
),
);
}
protected function renderActionEffectDescription($type, $data) {
switch ($type) {
case self::DO_BLOCK:
return pht('Blocked push.');
}
}
}
| php | Apache-2.0 | 5720a38cfe95b00ca4be5016dd0d2f3195f4fa04 | 2026-01-04T15:03:23.651835Z | false |
phacility/phabricator | https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/diffusion/herald/DiffusionCommitDiffContentRemovedHeraldField.php | src/applications/diffusion/herald/DiffusionCommitDiffContentRemovedHeraldField.php | <?php
final class DiffusionCommitDiffContentRemovedHeraldField
extends DiffusionCommitHeraldField {
const FIELDCONST = 'diffusion.commit.diff.old';
public function getHeraldFieldName() {
return pht('Diff content removed');
}
public function getFieldGroupKey() {
return DiffusionChangeHeraldFieldGroup::FIELDGROUPKEY;
}
public function getHeraldFieldValue($object) {
return $this->getAdapter()->loadDiffContent('-');
}
protected function getHeraldFieldStandardType() {
return self::STANDARD_TEXT_MAP;
}
}
| php | Apache-2.0 | 5720a38cfe95b00ca4be5016dd0d2f3195f4fa04 | 2026-01-04T15:03:23.651835Z | false |
phacility/phabricator | https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/diffusion/herald/DiffusionPreCommitContentPusherIsCommitterHeraldField.php | src/applications/diffusion/herald/DiffusionPreCommitContentPusherIsCommitterHeraldField.php | <?php
final class DiffusionPreCommitContentPusherIsCommitterHeraldField
extends DiffusionPreCommitContentHeraldField {
const FIELDCONST = 'diffusion.pre.content.pusher.is-committer';
public function getHeraldFieldName() {
return pht('Pusher is committer');
}
public function getHeraldFieldValue($object) {
$pusher = $this->getAdapter()->getHookEngine()->getViewer()->getPHID();
$committer = $this->getAdapter()->getCommitterPHID();
return ($pusher === $committer);
}
protected function getHeraldFieldStandardType() {
return HeraldField::STANDARD_BOOL;
}
}
| php | Apache-2.0 | 5720a38cfe95b00ca4be5016dd0d2f3195f4fa04 | 2026-01-04T15:03:23.651835Z | false |
phacility/phabricator | https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/diffusion/herald/DiffusionCommitMessageHeraldField.php | src/applications/diffusion/herald/DiffusionCommitMessageHeraldField.php | <?php
final class DiffusionCommitMessageHeraldField
extends DiffusionCommitHeraldField {
const FIELDCONST = 'diffusion.commit.message';
public function getHeraldFieldName() {
return pht('Commit message');
}
public function getHeraldFieldValue($object) {
return $object->getCommitData()->getCommitMessage();
}
protected function getHeraldFieldStandardType() {
return self::STANDARD_TEXT;
}
}
| php | Apache-2.0 | 5720a38cfe95b00ca4be5016dd0d2f3195f4fa04 | 2026-01-04T15:03:23.651835Z | false |
phacility/phabricator | https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/diffusion/herald/DiffusionCommitRevisionReviewersHeraldField.php | src/applications/diffusion/herald/DiffusionCommitRevisionReviewersHeraldField.php | <?php
final class DiffusionCommitRevisionReviewersHeraldField
extends DiffusionCommitHeraldField {
const FIELDCONST = 'diffusion.commit.revision.reviewers';
public function getHeraldFieldName() {
return pht('Differential reviewers');
}
public function getFieldGroupKey() {
return HeraldRelatedFieldGroup::FIELDGROUPKEY;
}
public function getHeraldFieldValue($object) {
$revision = $this->getAdapter()->loadDifferentialRevision();
if (!$revision) {
return array();
}
return $revision->getReviewerPHIDs();
}
protected function getHeraldFieldStandardType() {
return self::STANDARD_PHID_LIST;
}
protected function getDatasource() {
return new DifferentialReviewerDatasource();
}
}
| php | Apache-2.0 | 5720a38cfe95b00ca4be5016dd0d2f3195f4fa04 | 2026-01-04T15:03:23.651835Z | false |
phacility/phabricator | https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/diffusion/herald/DiffusionPreCommitContentPackageOwnerHeraldField.php | src/applications/diffusion/herald/DiffusionPreCommitContentPackageOwnerHeraldField.php | <?php
final class DiffusionPreCommitContentPackageOwnerHeraldField
extends DiffusionPreCommitContentHeraldField {
const FIELDCONST = 'diffusion.pre.content.package.owners';
public function getHeraldFieldName() {
return pht('Affected package owners');
}
public function getFieldGroupKey() {
return HeraldRelatedFieldGroup::FIELDGROUPKEY;
}
public function getHeraldFieldValue($object) {
$packages = $this->getAdapter()->loadAffectedPackages();
if (!$packages) {
return array();
}
$owners = PhabricatorOwnersOwner::loadAllForPackages($packages);
return mpull($owners, 'getUserPHID');
}
protected function getHeraldFieldStandardType() {
return self::STANDARD_PHID_LIST;
}
protected function getDatasource() {
return new PhabricatorProjectOrUserDatasource();
}
}
| php | Apache-2.0 | 5720a38cfe95b00ca4be5016dd0d2f3195f4fa04 | 2026-01-04T15:03:23.651835Z | false |
phacility/phabricator | https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/diffusion/herald/DiffusionPreCommitRefPusherProjectsHeraldField.php | src/applications/diffusion/herald/DiffusionPreCommitRefPusherProjectsHeraldField.php | <?php
final class DiffusionPreCommitRefPusherProjectsHeraldField
extends DiffusionPreCommitRefHeraldField {
const FIELDCONST = 'diffusion.pre.ref.pusher.projects';
public function getHeraldFieldName() {
return pht("Pusher's projects");
}
public function getHeraldFieldValue($object) {
return $this->getAdapter()
->getHookEngine()
->loadViewerProjectPHIDsForHerald();
}
protected function getHeraldFieldStandardType() {
return HeraldField::STANDARD_PHID_LIST;
}
protected function getDatasource() {
return new PhabricatorProjectDatasource();
}
}
| php | Apache-2.0 | 5720a38cfe95b00ca4be5016dd0d2f3195f4fa04 | 2026-01-04T15:03:23.651835Z | false |
phacility/phabricator | https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/diffusion/herald/DiffusionPreCommitContentMergeHeraldField.php | src/applications/diffusion/herald/DiffusionPreCommitContentMergeHeraldField.php | <?php
final class DiffusionPreCommitContentMergeHeraldField
extends DiffusionPreCommitContentHeraldField {
const FIELDCONST = 'diffusion.pre.content.merge';
public function getHeraldFieldName() {
return pht('Is merge commit');
}
public function getHeraldFieldValue($object) {
return $this->getAdapter()->getIsMergeCommit();
}
protected function getHeraldFieldStandardType() {
return HeraldField::STANDARD_BOOL;
}
}
| php | Apache-2.0 | 5720a38cfe95b00ca4be5016dd0d2f3195f4fa04 | 2026-01-04T15:03:23.651835Z | false |
phacility/phabricator | https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/diffusion/herald/DiffusionCommitDiffContentAddedHeraldField.php | src/applications/diffusion/herald/DiffusionCommitDiffContentAddedHeraldField.php | <?php
final class DiffusionCommitDiffContentAddedHeraldField
extends DiffusionCommitHeraldField {
const FIELDCONST = 'diffusion.commit.diff.new';
public function getHeraldFieldName() {
return pht('Diff content added');
}
public function getFieldGroupKey() {
return DiffusionChangeHeraldFieldGroup::FIELDGROUPKEY;
}
public function getHeraldFieldValue($object) {
return $this->getAdapter()->loadDiffContent('+');
}
protected function getHeraldFieldStandardType() {
return self::STANDARD_TEXT_MAP;
}
}
| php | Apache-2.0 | 5720a38cfe95b00ca4be5016dd0d2f3195f4fa04 | 2026-01-04T15:03:23.651835Z | false |
phacility/phabricator | https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/diffusion/herald/DiffusionCommitReviewerHeraldField.php | src/applications/diffusion/herald/DiffusionCommitReviewerHeraldField.php | <?php
final class DiffusionCommitReviewerHeraldField
extends DiffusionCommitHeraldField {
const FIELDCONST = 'diffusion.commit.reviewer';
public function getHeraldFieldName() {
return pht('Reviewer (Deprecated)');
}
public function getFieldGroupKey() {
return HeraldDeprecatedFieldGroup::FIELDGROUPKEY;
}
public function getHeraldFieldValue($object) {
return $object->getCommitData()->getCommitDetail('reviewerPHID');
}
protected function getHeraldFieldStandardType() {
return self::STANDARD_PHID_NULLABLE;
}
protected function getDatasource() {
return new PhabricatorPeopleDatasource();
}
}
| php | Apache-2.0 | 5720a38cfe95b00ca4be5016dd0d2f3195f4fa04 | 2026-01-04T15:03:23.651835Z | false |
phacility/phabricator | https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/diffusion/herald/DiffusionCommitRepositoryProjectsHeraldField.php | src/applications/diffusion/herald/DiffusionCommitRepositoryProjectsHeraldField.php | <?php
final class DiffusionCommitRepositoryProjectsHeraldField
extends DiffusionCommitHeraldField {
const FIELDCONST = 'diffusion.commit.repository.projects';
public function getHeraldFieldName() {
return pht('Repository projects');
}
public function getHeraldFieldValue($object) {
return PhabricatorEdgeQuery::loadDestinationPHIDs(
$object->getRepository()->getPHID(),
PhabricatorProjectObjectHasProjectEdgeType::EDGECONST);
}
protected function getHeraldFieldStandardType() {
return self::STANDARD_PHID_LIST;
}
protected function getDatasource() {
return new PhabricatorProjectDatasource();
}
}
| php | Apache-2.0 | 5720a38cfe95b00ca4be5016dd0d2f3195f4fa04 | 2026-01-04T15:03:23.651835Z | false |
phacility/phabricator | https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/diffusion/herald/DiffusionCommitCommitterProjectsHeraldField.php | src/applications/diffusion/herald/DiffusionCommitCommitterProjectsHeraldField.php | <?php
final class DiffusionCommitCommitterProjectsHeraldField
extends DiffusionCommitHeraldField {
const FIELDCONST = 'diffusion.commit.committer.projects';
public function getHeraldFieldName() {
return pht("Committer's projects");
}
public function getHeraldFieldValue($object) {
$adapter = $this->getAdapter();
$viewer = $adapter->getViewer();
$committer_phid = $adapter->getCommitterPHID();
if (!$committer_phid) {
return array();
}
$projects = id(new PhabricatorProjectQuery())
->setViewer($viewer)
->withMemberPHIDs(array($committer_phid))
->execute();
return mpull($projects, 'getPHID');
}
protected function getHeraldFieldStandardType() {
return self::STANDARD_PHID_LIST;
}
protected function getDatasource() {
return new PhabricatorProjectDatasource();
}
}
| php | Apache-2.0 | 5720a38cfe95b00ca4be5016dd0d2f3195f4fa04 | 2026-01-04T15:03:23.651835Z | false |
phacility/phabricator | https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/diffusion/herald/DiffusionCommitRevisionAcceptedHeraldField.php | src/applications/diffusion/herald/DiffusionCommitRevisionAcceptedHeraldField.php | <?php
final class DiffusionCommitRevisionAcceptedHeraldField
extends DiffusionCommitHeraldField {
const FIELDCONST = 'diffusion.commit.revision.accepted';
public function getHeraldFieldName() {
return pht('Accepted Differential revision');
}
public function getFieldGroupKey() {
return HeraldRelatedFieldGroup::FIELDGROUPKEY;
}
public function getHeraldFieldValue($object) {
$revision = $this->getAdapter()->loadDifferentialRevision();
if (!$revision) {
return null;
}
if ($revision->isAccepted()) {
return $revision->getPHID();
}
$was_accepted = DifferentialRevision::PROPERTY_CLOSED_FROM_ACCEPTED;
if ($revision->isPublished()) {
if ($revision->getProperty($was_accepted)) {
return $revision->getPHID();
}
}
return null;
}
protected function getHeraldFieldStandardType() {
return self::STANDARD_PHID_BOOL;
}
}
| php | Apache-2.0 | 5720a38cfe95b00ca4be5016dd0d2f3195f4fa04 | 2026-01-04T15:03:23.651835Z | false |
phacility/phabricator | https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/diffusion/herald/DiffusionPreCommitRefRepositoryProjectsHeraldField.php | src/applications/diffusion/herald/DiffusionPreCommitRefRepositoryProjectsHeraldField.php | <?php
final class DiffusionPreCommitRefRepositoryProjectsHeraldField
extends DiffusionPreCommitRefHeraldField {
const FIELDCONST = 'diffusion.pre.ref.repository.projects';
public function getHeraldFieldName() {
return pht('Repository projects');
}
public function getHeraldFieldValue($object) {
return PhabricatorEdgeQuery::loadDestinationPHIDs(
$this->getAdapter()->getHookEngine()->getRepository()->getPHID(),
PhabricatorProjectObjectHasProjectEdgeType::EDGECONST);
}
protected function getHeraldFieldStandardType() {
return self::STANDARD_PHID_LIST;
}
protected function getDatasource() {
return new PhabricatorProjectDatasource();
}
}
| php | Apache-2.0 | 5720a38cfe95b00ca4be5016dd0d2f3195f4fa04 | 2026-01-04T15:03:23.651835Z | false |
phacility/phabricator | https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/diffusion/herald/DiffusionPreCommitContentAuthorPackagesHeraldField.php | src/applications/diffusion/herald/DiffusionPreCommitContentAuthorPackagesHeraldField.php | <?php
final class DiffusionPreCommitContentAuthorPackagesHeraldField
extends DiffusionPreCommitContentHeraldField {
const FIELDCONST = 'diffusion.pre.commit.author.packages';
public function getHeraldFieldName() {
return pht("Author's packages");
}
public function getHeraldFieldValue($object) {
$adapter = $this->getAdapter();
$viewer = $adapter->getViewer();
$author_phid = $adapter->getAuthorPHID();
if (!$author_phid) {
return array();
}
$packages = id(new PhabricatorOwnersPackageQuery())
->setViewer($viewer)
->withAuthorityPHIDs(array($author_phid))
->execute();
return mpull($packages, 'getPHID');
}
protected function getHeraldFieldStandardType() {
return self::STANDARD_PHID_LIST;
}
protected function getDatasource() {
return new PhabricatorOwnersPackageDatasource();
}
}
| php | Apache-2.0 | 5720a38cfe95b00ca4be5016dd0d2f3195f4fa04 | 2026-01-04T15:03:23.651835Z | false |
phacility/phabricator | https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/diffusion/herald/DiffusionCommitPackageHeraldField.php | src/applications/diffusion/herald/DiffusionCommitPackageHeraldField.php | <?php
final class DiffusionCommitPackageHeraldField
extends DiffusionCommitHeraldField {
const FIELDCONST = 'diffusion.commit.package';
public function getHeraldFieldName() {
return pht('Affected packages');
}
public function getFieldGroupKey() {
return HeraldRelatedFieldGroup::FIELDGROUPKEY;
}
public function getHeraldFieldValue($object) {
$packages = $this->getAdapter()->loadAffectedPackages();
return mpull($packages, 'getPHID');
}
protected function getHeraldFieldStandardType() {
return self::STANDARD_PHID_LIST;
}
protected function getDatasource() {
return new PhabricatorOwnersPackageDatasource();
}
}
| php | Apache-2.0 | 5720a38cfe95b00ca4be5016dd0d2f3195f4fa04 | 2026-01-04T15:03:23.651835Z | false |
phacility/phabricator | https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/diffusion/herald/DiffusionCommitRepositoryHeraldField.php | src/applications/diffusion/herald/DiffusionCommitRepositoryHeraldField.php | <?php
final class DiffusionCommitRepositoryHeraldField
extends DiffusionCommitHeraldField {
const FIELDCONST = 'diffusion.commit.repository';
public function getHeraldFieldName() {
return pht('Repository');
}
public function getHeraldFieldValue($object) {
return $object->getRepository()->getPHID();
}
protected function getHeraldFieldStandardType() {
return self::STANDARD_PHID;
}
protected function getDatasource() {
return new DiffusionRepositoryDatasource();
}
}
| php | Apache-2.0 | 5720a38cfe95b00ca4be5016dd0d2f3195f4fa04 | 2026-01-04T15:03:23.651835Z | false |
phacility/phabricator | https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/diffusion/herald/DiffusionPreCommitContentDiffContentAddedHeraldField.php | src/applications/diffusion/herald/DiffusionPreCommitContentDiffContentAddedHeraldField.php | <?php
final class DiffusionPreCommitContentDiffContentAddedHeraldField
extends DiffusionPreCommitContentHeraldField {
const FIELDCONST = 'diffusion.pre.commit.diff.new';
public function getHeraldFieldName() {
return pht('Added diff content');
}
public function getFieldGroupKey() {
return DiffusionChangeHeraldFieldGroup::FIELDGROUPKEY;
}
public function getHeraldFieldValue($object) {
return $this->getAdapter()->getDiffContent('+');
}
protected function getHeraldFieldStandardType() {
return self::STANDARD_TEXT_MAP;
}
}
| php | Apache-2.0 | 5720a38cfe95b00ca4be5016dd0d2f3195f4fa04 | 2026-01-04T15:03:23.651835Z | false |
phacility/phabricator | https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/diffusion/herald/DiffusionAuditorsAddAuditorsHeraldAction.php | src/applications/diffusion/herald/DiffusionAuditorsAddAuditorsHeraldAction.php | <?php
final class DiffusionAuditorsAddAuditorsHeraldAction
extends DiffusionAuditorsHeraldAction {
const ACTIONCONST = 'diffusion.auditors.add';
public function getHeraldActionName() {
return pht('Add auditors');
}
public function supportsRuleType($rule_type) {
return ($rule_type != HeraldRuleTypeConfig::RULE_TYPE_PERSONAL);
}
public function applyEffect($object, HeraldEffect $effect) {
$rule = $effect->getRule();
return $this->applyAuditors($effect->getTarget(), $rule);
}
public function getHeraldActionStandardType() {
return self::STANDARD_PHID_LIST;
}
protected function getDatasource() {
return new DiffusionAuditorDatasource();
}
public function renderActionDescription($value) {
return pht('Add auditors: %s.', $this->renderHandleList($value));
}
public function getPHIDsAffectedByAction(HeraldActionRecord $record) {
return $record->getTarget();
}
}
| php | Apache-2.0 | 5720a38cfe95b00ca4be5016dd0d2f3195f4fa04 | 2026-01-04T15:03:23.651835Z | false |
phacility/phabricator | https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/diffusion/herald/DiffusionPreCommitContentCommitterProjectsHeraldField.php | src/applications/diffusion/herald/DiffusionPreCommitContentCommitterProjectsHeraldField.php | <?php
final class DiffusionPreCommitContentCommitterProjectsHeraldField
extends DiffusionPreCommitContentHeraldField {
const FIELDCONST = 'diffusion.pre.commit.committer.projects';
public function getHeraldFieldName() {
return pht("Committer's projects");
}
public function getHeraldFieldValue($object) {
$adapter = $this->getAdapter();
$viewer = $adapter->getViewer();
$committer_phid = $adapter->getCommitterPHID();
if (!$committer_phid) {
return array();
}
$projects = id(new PhabricatorProjectQuery())
->setViewer($viewer)
->withMemberPHIDs(array($committer_phid))
->execute();
return mpull($projects, 'getPHID');
}
protected function getHeraldFieldStandardType() {
return self::STANDARD_PHID_LIST;
}
protected function getDatasource() {
return new PhabricatorProjectDatasource();
}
}
| php | Apache-2.0 | 5720a38cfe95b00ca4be5016dd0d2f3195f4fa04 | 2026-01-04T15:03:23.651835Z | false |
phacility/phabricator | https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/diffusion/herald/HeraldPreCommitRefAdapter.php | src/applications/diffusion/herald/HeraldPreCommitRefAdapter.php | <?php
final class HeraldPreCommitRefAdapter extends HeraldPreCommitAdapter {
public function getAdapterContentName() {
return pht('Commit Hook: Branches/Tags/Bookmarks');
}
public function getAdapterSortOrder() {
return 2000;
}
public function getAdapterContentDescription() {
return pht(
"React to branches and tags being pushed to hosted repositories.\n".
"Hook rules can block changes and send push summary mail.");
}
public function isPreCommitRefAdapter() {
return true;
}
public function getHeraldName() {
return pht('Push Log (Ref)');
}
}
| php | Apache-2.0 | 5720a38cfe95b00ca4be5016dd0d2f3195f4fa04 | 2026-01-04T15:03:23.651835Z | false |
phacility/phabricator | https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/diffusion/herald/DiffusionPreCommitContentAuthorProjectsHeraldField.php | src/applications/diffusion/herald/DiffusionPreCommitContentAuthorProjectsHeraldField.php | <?php
final class DiffusionPreCommitContentAuthorProjectsHeraldField
extends DiffusionPreCommitContentHeraldField {
const FIELDCONST = 'diffusion.pre.commit.author.projects';
public function getHeraldFieldName() {
return pht("Author's projects");
}
public function getHeraldFieldValue($object) {
$adapter = $this->getAdapter();
$viewer = $adapter->getViewer();
$author_phid = $adapter->getAuthorPHID();
if (!$author_phid) {
return array();
}
$projects = id(new PhabricatorProjectQuery())
->setViewer($viewer)
->withMemberPHIDs(array($author_phid))
->execute();
return mpull($projects, 'getPHID');
}
protected function getHeraldFieldStandardType() {
return self::STANDARD_PHID_LIST;
}
protected function getDatasource() {
return new PhabricatorProjectDatasource();
}
}
| php | Apache-2.0 | 5720a38cfe95b00ca4be5016dd0d2f3195f4fa04 | 2026-01-04T15:03:23.651835Z | false |
phacility/phabricator | https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/diffusion/herald/DiffusionCommitCommitterPackagesHeraldField.php | src/applications/diffusion/herald/DiffusionCommitCommitterPackagesHeraldField.php | <?php
final class DiffusionCommitCommitterPackagesHeraldField
extends DiffusionCommitHeraldField {
const FIELDCONST = 'diffusion.commit.committer.packages';
public function getHeraldFieldName() {
return pht("Committer's packages");
}
public function getHeraldFieldValue($object) {
$adapter = $this->getAdapter();
$viewer = $adapter->getViewer();
$committer_phid = $adapter->getAuthorPHID();
if (!$committer_phid) {
return array();
}
$packages = id(new PhabricatorOwnersPackageQuery())
->setViewer($viewer)
->withAuthorityPHIDs(array($committer_phid))
->execute();
return mpull($packages, 'getPHID');
}
protected function getHeraldFieldStandardType() {
return self::STANDARD_PHID_LIST;
}
protected function getDatasource() {
return new PhabricatorOwnersPackageDatasource();
}
}
| php | Apache-2.0 | 5720a38cfe95b00ca4be5016dd0d2f3195f4fa04 | 2026-01-04T15:03:23.651835Z | false |
phacility/phabricator | https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/diffusion/herald/DiffusionPreCommitContentDiffEnormousHeraldField.php | src/applications/diffusion/herald/DiffusionPreCommitContentDiffEnormousHeraldField.php | <?php
final class DiffusionPreCommitContentDiffEnormousHeraldField
extends DiffusionPreCommitContentHeraldField {
const FIELDCONST = 'diffusion.pre.content.diff.enormous';
public function getHeraldFieldName() {
return pht('Diff is enormous');
}
public function getFieldGroupKey() {
return DiffusionChangeHeraldFieldGroup::FIELDGROUPKEY;
}
public function getHeraldFieldValue($object) {
return $this->getAdapter()->isDiffEnormous();
}
protected function getHeraldFieldStandardType() {
return HeraldField::STANDARD_BOOL;
}
}
| php | Apache-2.0 | 5720a38cfe95b00ca4be5016dd0d2f3195f4fa04 | 2026-01-04T15:03:23.651835Z | false |
phacility/phabricator | https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/diffusion/herald/DiffusionCommitPackageAuditHeraldField.php | src/applications/diffusion/herald/DiffusionCommitPackageAuditHeraldField.php | <?php
final class DiffusionCommitPackageAuditHeraldField
extends DiffusionCommitHeraldField {
const FIELDCONST = 'diffusion.commit.package.audit';
public function getHeraldFieldName() {
return pht('Affected packages that need audit');
}
public function getFieldGroupKey() {
return HeraldRelatedFieldGroup::FIELDGROUPKEY;
}
public function getHeraldFieldValue($object) {
$packages = $this->getAdapter()->loadAuditNeededPackages();
if (!$packages) {
return array();
}
return mpull($packages, 'getPHID');
}
protected function getHeraldFieldStandardType() {
return self::STANDARD_PHID_LIST;
}
protected function getDatasource() {
return new PhabricatorOwnersPackageDatasource();
}
}
| php | Apache-2.0 | 5720a38cfe95b00ca4be5016dd0d2f3195f4fa04 | 2026-01-04T15:03:23.651835Z | false |
phacility/phabricator | https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/diffusion/herald/DiffusionCommitPackageOwnerHeraldField.php | src/applications/diffusion/herald/DiffusionCommitPackageOwnerHeraldField.php | <?php
final class DiffusionCommitPackageOwnerHeraldField
extends DiffusionCommitHeraldField {
const FIELDCONST = 'diffusion.commit.package.owners';
public function getHeraldFieldName() {
return pht('Affected package owners');
}
public function getFieldGroupKey() {
return HeraldRelatedFieldGroup::FIELDGROUPKEY;
}
public function getHeraldFieldValue($object) {
$packages = $this->getAdapter()->loadAffectedPackages();
if (!$packages) {
return array();
}
$owners = PhabricatorOwnersOwner::loadAllForPackages($packages);
return mpull($owners, 'getUserPHID');
}
protected function getHeraldFieldStandardType() {
return self::STANDARD_PHID_LIST;
}
protected function getDatasource() {
return new PhabricatorProjectOrUserDatasource();
}
}
| php | Apache-2.0 | 5720a38cfe95b00ca4be5016dd0d2f3195f4fa04 | 2026-01-04T15:03:23.651835Z | false |
phacility/phabricator | https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/diffusion/herald/DiffusionCommitRevisionHeraldField.php | src/applications/diffusion/herald/DiffusionCommitRevisionHeraldField.php | <?php
final class DiffusionCommitRevisionHeraldField
extends DiffusionCommitHeraldField {
const FIELDCONST = 'diffusion.commit.revision';
public function getHeraldFieldName() {
return pht('Differential revision');
}
public function getFieldGroupKey() {
return HeraldRelatedFieldGroup::FIELDGROUPKEY;
}
public function getHeraldFieldValue($object) {
$revision = $this->getAdapter()->loadDifferentialRevision();
if (!$revision) {
return null;
}
return $revision->getPHID();
}
protected function getHeraldFieldStandardType() {
return self::STANDARD_PHID_BOOL;
}
}
| php | Apache-2.0 | 5720a38cfe95b00ca4be5016dd0d2f3195f4fa04 | 2026-01-04T15:03:23.651835Z | false |
phacility/phabricator | https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/diffusion/herald/DiffusionPreCommitContentHeraldField.php | src/applications/diffusion/herald/DiffusionPreCommitContentHeraldField.php | <?php
abstract class DiffusionPreCommitContentHeraldField extends HeraldField {
public function supportsObject($object) {
if (!($object instanceof PhabricatorRepositoryPushLog)) {
return false;
}
if ($this->getAdapter()->isPreCommitRefAdapter()) {
return false;
}
return true;
}
public function getFieldGroupKey() {
return DiffusionCommitHeraldFieldGroup::FIELDGROUPKEY;
}
}
| php | Apache-2.0 | 5720a38cfe95b00ca4be5016dd0d2f3195f4fa04 | 2026-01-04T15:03:23.651835Z | false |
phacility/phabricator | https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/diffusion/herald/HeraldPreCommitContentAdapter.php | src/applications/diffusion/herald/HeraldPreCommitContentAdapter.php | <?php
final class HeraldPreCommitContentAdapter extends HeraldPreCommitAdapter {
private $changesets;
private $commitRef;
private $fields;
private $revision = false;
private $affectedPackages;
private $identityCache = array();
public function getAdapterContentName() {
return pht('Commit Hook: Commit Content');
}
public function getAdapterSortOrder() {
return 2500;
}
public function getAdapterContentDescription() {
return pht(
"React to commits being pushed to hosted repositories.\n".
"Hook rules can block changes and send push summary mail.");
}
public function isPreCommitRefAdapter() {
return false;
}
public function getHeraldName() {
return pht('Push Log (Content)');
}
public function isDiffEnormous() {
$this->getDiffContent('*');
return ($this->changesets instanceof Exception);
}
public function getDiffContent($type) {
if ($this->changesets === null) {
try {
$this->changesets = $this->getHookEngine()->getChangesetsForCommit(
$this->getObject()->getRefNew());
} catch (Exception $ex) {
$this->changesets = $ex;
}
}
if ($this->changesets instanceof Exception) {
$ex_class = get_class($this->changesets);
$ex_message = $this->changesets->getMessage();
if ($type === 'name') {
return array("<{$ex_class}: {$ex_message}>");
} else {
return array("<{$ex_class}>" => $ex_message);
}
}
$result = array();
if ($type === 'name') {
foreach ($this->changesets as $change) {
$result[] = $change->getFilename();
}
} else {
foreach ($this->changesets as $change) {
$lines = array();
foreach ($change->getHunks() as $hunk) {
switch ($type) {
case '-':
$lines[] = $hunk->makeOldFile();
break;
case '+':
$lines[] = $hunk->makeNewFile();
break;
case '*':
default:
$lines[] = $hunk->makeChanges();
break;
}
}
$result[$change->getFilename()] = implode('', $lines);
}
}
return $result;
}
public function getCommitRef() {
if ($this->commitRef === null) {
$this->commitRef = $this->getHookEngine()->loadCommitRefForCommit(
$this->getObject()->getRefNew());
}
return $this->commitRef;
}
public function getAuthorPHID() {
$repository = $this->getHookEngine()->getRepository();
$vcs = $repository->getVersionControlSystem();
switch ($vcs) {
case PhabricatorRepositoryType::REPOSITORY_TYPE_GIT:
case PhabricatorRepositoryType::REPOSITORY_TYPE_MERCURIAL:
$ref = $this->getCommitRef();
$author = $ref->getAuthor();
if (!strlen($author)) {
return null;
}
return $this->lookupUser($author);
case PhabricatorRepositoryType::REPOSITORY_TYPE_SVN:
// In Subversion, the pusher is always the author.
return $this->getHookEngine()->getViewer()->getPHID();
}
}
public function getCommitterPHID() {
$repository = $this->getHookEngine()->getRepository();
$vcs = $repository->getVersionControlSystem();
switch ($vcs) {
case PhabricatorRepositoryType::REPOSITORY_TYPE_GIT:
case PhabricatorRepositoryType::REPOSITORY_TYPE_MERCURIAL:
// If there's no committer information, we're going to return the
// author instead. However, if there's committer information and we
// can't resolve it, return `null`.
$ref = $this->getCommitRef();
$committer = $ref->getCommitter();
if (!strlen($committer)) {
return $this->getAuthorPHID();
}
return $this->lookupUser($committer);
case PhabricatorRepositoryType::REPOSITORY_TYPE_SVN:
// In Subversion, the pusher is always the committer.
return $this->getHookEngine()->getViewer()->getPHID();
}
}
public function getAuthorRaw() {
$repository = $this->getHookEngine()->getRepository();
$vcs = $repository->getVersionControlSystem();
switch ($vcs) {
case PhabricatorRepositoryType::REPOSITORY_TYPE_GIT:
case PhabricatorRepositoryType::REPOSITORY_TYPE_MERCURIAL:
$ref = $this->getCommitRef();
return $ref->getAuthor();
case PhabricatorRepositoryType::REPOSITORY_TYPE_SVN:
// In Subversion, the pusher is always the author.
return $this->getHookEngine()->getViewer()->getUsername();
}
}
public function getCommitterRaw() {
$repository = $this->getHookEngine()->getRepository();
$vcs = $repository->getVersionControlSystem();
switch ($vcs) {
case PhabricatorRepositoryType::REPOSITORY_TYPE_GIT:
case PhabricatorRepositoryType::REPOSITORY_TYPE_MERCURIAL:
// Here, if there's no committer, we're going to return the author
// instead.
$ref = $this->getCommitRef();
$committer = $ref->getCommitter();
if (strlen($committer)) {
return $committer;
}
return $ref->getAuthor();
case PhabricatorRepositoryType::REPOSITORY_TYPE_SVN:
// In Subversion, the pusher is always the committer.
return $this->getHookEngine()->getViewer()->getUsername();
}
}
private function lookupUser($raw_identity) {
// See T13480. After the move to repository identities, we want to look
// users up in the identity table. If you push a commit which is authored
// by "A Duck <duck@example.org>" and that identity is bound to user
// "@mallard" in the identity table, Herald should see the author of the
// commit as "@mallard" when evaluating pre-commit content rules.
if (!array_key_exists($raw_identity, $this->identityCache)) {
$repository = $this->getHookEngine()->getRepository();
$viewer = $this->getHookEngine()->getViewer();
$identity_engine = id(new DiffusionRepositoryIdentityEngine())
->setViewer($viewer);
// We must provide a "sourcePHID" when resolving identities, but don't
// have a legitimate one yet. Just use the repository PHID as a
// reasonable value. This won't actually be written to storage.
$source_phid = $repository->getPHID();
$identity_engine->setSourcePHID($source_phid);
// If the identity doesn't exist yet, we don't want to create it if
// we haven't seen it before. It will be created later when we actually
// import the commit.
$identity_engine->setDryRun(true);
$author_identity = $identity_engine->newResolvedIdentity($raw_identity);
$effective_phid = $author_identity->getCurrentEffectiveUserPHID();
$this->identityCache[$raw_identity] = $effective_phid;
}
return $this->identityCache[$raw_identity];
}
private function getCommitFields() {
if ($this->fields === null) {
$this->fields = id(new DiffusionLowLevelCommitFieldsQuery())
->setRepository($this->getHookEngine()->getRepository())
->withCommitRef($this->getCommitRef())
->execute();
}
return $this->fields;
}
public function getRevision() {
if ($this->revision === false) {
$fields = $this->getCommitFields();
$revision_id = idx($fields, 'revisionID');
if (!$revision_id) {
$this->revision = null;
} else {
$this->revision = id(new DifferentialRevisionQuery())
->setViewer(PhabricatorUser::getOmnipotentUser())
->withIDs(array($revision_id))
->needReviewers(true)
->executeOne();
}
}
return $this->revision;
}
public function getIsMergeCommit() {
$repository = $this->getHookEngine()->getRepository();
$vcs = $repository->getVersionControlSystem();
switch ($vcs) {
case PhabricatorRepositoryType::REPOSITORY_TYPE_GIT:
case PhabricatorRepositoryType::REPOSITORY_TYPE_MERCURIAL:
$parents = id(new DiffusionLowLevelParentsQuery())
->setRepository($repository)
->withIdentifier($this->getObject()->getRefNew())
->execute();
return (count($parents) > 1);
case PhabricatorRepositoryType::REPOSITORY_TYPE_SVN:
// NOTE: For now, we ignore "svn:mergeinfo" at all levels. We might
// change this some day, but it's not nearly as clear a signal as
// ancestry is in Git/Mercurial.
return false;
}
}
public function getBranches() {
return $this->getHookEngine()->loadBranches(
$this->getObject()->getRefNew());
}
public function loadAffectedPackages() {
if ($this->affectedPackages === null) {
$packages = PhabricatorOwnersPackage::loadAffectedPackages(
$this->getHookEngine()->getRepository(),
$this->getDiffContent('name'));
$this->affectedPackages = $packages;
}
return $this->affectedPackages;
}
}
| php | Apache-2.0 | 5720a38cfe95b00ca4be5016dd0d2f3195f4fa04 | 2026-01-04T15:03:23.651835Z | false |
phacility/phabricator | https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/diffusion/herald/DiffusionCommitAuthorPackagesHeraldField.php | src/applications/diffusion/herald/DiffusionCommitAuthorPackagesHeraldField.php | <?php
final class DiffusionCommitAuthorPackagesHeraldField
extends DiffusionCommitHeraldField {
const FIELDCONST = 'diffusion.commit.author.packages';
public function getHeraldFieldName() {
return pht("Author's packages");
}
public function getHeraldFieldValue($object) {
$adapter = $this->getAdapter();
$viewer = $adapter->getViewer();
$author_phid = $adapter->getAuthorPHID();
if (!$author_phid) {
return array();
}
$packages = id(new PhabricatorOwnersPackageQuery())
->setViewer($viewer)
->withAuthorityPHIDs(array($author_phid))
->execute();
return mpull($packages, 'getPHID');
}
protected function getHeraldFieldStandardType() {
return self::STANDARD_PHID_LIST;
}
protected function getDatasource() {
return new PhabricatorOwnersPackageDatasource();
}
}
| php | Apache-2.0 | 5720a38cfe95b00ca4be5016dd0d2f3195f4fa04 | 2026-01-04T15:03:23.651835Z | false |
phacility/phabricator | https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/diffusion/herald/DiffusionCommitAffectedFilesHeraldField.php | src/applications/diffusion/herald/DiffusionCommitAffectedFilesHeraldField.php | <?php
final class DiffusionCommitAffectedFilesHeraldField
extends DiffusionCommitHeraldField {
const FIELDCONST = 'diffusion.commit.affected';
public function getHeraldFieldName() {
return pht('Affected files');
}
public function getFieldGroupKey() {
return DiffusionChangeHeraldFieldGroup::FIELDGROUPKEY;
}
public function getHeraldFieldValue($object) {
return $this->getAdapter()->loadAffectedPaths();
}
protected function getHeraldFieldStandardType() {
return self::STANDARD_TEXT_LIST;
}
}
| php | Apache-2.0 | 5720a38cfe95b00ca4be5016dd0d2f3195f4fa04 | 2026-01-04T15:03:23.651835Z | false |
phacility/phabricator | https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/diffusion/herald/DiffusionPreCommitContentPusherProjectsHeraldField.php | src/applications/diffusion/herald/DiffusionPreCommitContentPusherProjectsHeraldField.php | <?php
final class DiffusionPreCommitContentPusherProjectsHeraldField
extends DiffusionPreCommitContentHeraldField {
const FIELDCONST = 'diffusion.pre.content.pusher.projects';
public function getHeraldFieldName() {
return pht("Pusher's projects");
}
public function getHeraldFieldValue($object) {
return $this->getAdapter()
->getHookEngine()
->loadViewerProjectPHIDsForHerald();
}
protected function getHeraldFieldStandardType() {
return HeraldField::STANDARD_PHID_LIST;
}
protected function getDatasource() {
return new PhabricatorProjectDatasource();
}
}
| php | Apache-2.0 | 5720a38cfe95b00ca4be5016dd0d2f3195f4fa04 | 2026-01-04T15:03:23.651835Z | false |
phacility/phabricator | https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/diffusion/herald/DiffusionCommitBranchesHeraldField.php | src/applications/diffusion/herald/DiffusionCommitBranchesHeraldField.php | <?php
final class DiffusionCommitBranchesHeraldField
extends DiffusionCommitHeraldField {
const FIELDCONST = 'diffusion.commit.branches';
public function getHeraldFieldName() {
return pht('Branches');
}
public function getHeraldFieldValue($object) {
$viewer = $this->getAdapter()->getViewer();
$commit = $object;
$repository = $object->getRepository();
$params = array(
'repository' => $repository->getPHID(),
'contains' => $commit->getCommitIdentifier(),
);
$result = id(new ConduitCall('diffusion.branchquery', $params))
->setUser($viewer)
->execute();
$refs = DiffusionRepositoryRef::loadAllFromDictionaries($result);
return mpull($refs, 'getShortName');
}
protected function getHeraldFieldStandardType() {
return self::STANDARD_TEXT_LIST;
}
}
| php | Apache-2.0 | 5720a38cfe95b00ca4be5016dd0d2f3195f4fa04 | 2026-01-04T15:03:23.651835Z | false |
phacility/phabricator | https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/diffusion/herald/DiffusionPreCommitContentCommitterHeraldField.php | src/applications/diffusion/herald/DiffusionPreCommitContentCommitterHeraldField.php | <?php
final class DiffusionPreCommitContentCommitterHeraldField
extends DiffusionPreCommitContentHeraldField {
const FIELDCONST = 'diffusion.pre.commit.committer';
public function getHeraldFieldName() {
return pht('Committer');
}
public function getHeraldFieldValue($object) {
return $this->getAdapter()->getCommitterPHID();
}
protected function getHeraldFieldStandardType() {
return self::STANDARD_PHID_NULLABLE;
}
protected function getDatasource() {
return new PhabricatorPeopleDatasource();
}
}
| php | Apache-2.0 | 5720a38cfe95b00ca4be5016dd0d2f3195f4fa04 | 2026-01-04T15:03:23.651835Z | false |
phacility/phabricator | https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/diffusion/herald/DiffusionPreCommitContentPusherHeraldField.php | src/applications/diffusion/herald/DiffusionPreCommitContentPusherHeraldField.php | <?php
final class DiffusionPreCommitContentPusherHeraldField
extends DiffusionPreCommitContentHeraldField {
const FIELDCONST = 'diffusion.pre.content.pusher';
public function getHeraldFieldName() {
return pht('Pusher');
}
public function getHeraldFieldValue($object) {
return $this->getAdapter()->getHookEngine()->getViewer()->getPHID();
}
protected function getHeraldFieldStandardType() {
return HeraldField::STANDARD_PHID;
}
protected function getDatasource() {
return new PhabricatorPeopleDatasource();
}
}
| php | Apache-2.0 | 5720a38cfe95b00ca4be5016dd0d2f3195f4fa04 | 2026-01-04T15:03:23.651835Z | false |
phacility/phabricator | https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/diffusion/herald/DiffusionCommitCommitterHeraldField.php | src/applications/diffusion/herald/DiffusionCommitCommitterHeraldField.php | <?php
final class DiffusionCommitCommitterHeraldField
extends DiffusionCommitHeraldField {
const FIELDCONST = 'diffusion.commit.committer';
public function getHeraldFieldName() {
return pht('Committer');
}
public function getHeraldFieldValue($object) {
return $this->getAdapter()->getCommitterPHID();
}
protected function getHeraldFieldStandardType() {
return self::STANDARD_PHID_NULLABLE;
}
protected function getDatasource() {
return new PhabricatorPeopleDatasource();
}
}
| php | Apache-2.0 | 5720a38cfe95b00ca4be5016dd0d2f3195f4fa04 | 2026-01-04T15:03:23.651835Z | false |
phacility/phabricator | https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/diffusion/herald/DiffusionCommitDiffContentHeraldField.php | src/applications/diffusion/herald/DiffusionCommitDiffContentHeraldField.php | <?php
final class DiffusionCommitDiffContentHeraldField
extends DiffusionCommitHeraldField {
const FIELDCONST = 'diffusion.commit.diff';
public function getHeraldFieldName() {
return pht('Diff content');
}
public function getFieldGroupKey() {
return DiffusionChangeHeraldFieldGroup::FIELDGROUPKEY;
}
public function getHeraldFieldValue($object) {
return $this->getAdapter()->loadDiffContent('*');
}
protected function getHeraldFieldStandardType() {
return self::STANDARD_TEXT_MAP;
}
}
| php | Apache-2.0 | 5720a38cfe95b00ca4be5016dd0d2f3195f4fa04 | 2026-01-04T15:03:23.651835Z | false |
phacility/phabricator | https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/diffusion/herald/DiffusionCommitAutocloseHeraldField.php | src/applications/diffusion/herald/DiffusionCommitAutocloseHeraldField.php | <?php
final class DiffusionCommitAutocloseHeraldField
extends DiffusionCommitHeraldField {
const FIELDCONST = 'diffusion.commit.autoclose';
public function getFieldGroupKey() {
return HeraldDeprecatedFieldGroup::FIELDGROUPKEY;
}
public function getHeraldFieldName() {
// Herald no longer triggers until a commit is reachable from a permanent
// ref, so this condition is always true by definition.
return pht('Commit Autocloses (Deprecated)');
}
public function getHeraldFieldValue($object) {
return true;
}
public function getHeraldFieldConditions() {
return array(
HeraldAdapter::CONDITION_UNCONDITIONALLY,
);
}
public function getHeraldFieldValueType($condition) {
return new HeraldEmptyFieldValue();
}
}
| php | Apache-2.0 | 5720a38cfe95b00ca4be5016dd0d2f3195f4fa04 | 2026-01-04T15:03:23.651835Z | false |
phacility/phabricator | https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/diffusion/herald/DiffusionPreCommitContentRevisionReviewersHeraldField.php | src/applications/diffusion/herald/DiffusionPreCommitContentRevisionReviewersHeraldField.php | <?php
final class DiffusionPreCommitContentRevisionReviewersHeraldField
extends DiffusionPreCommitContentHeraldField {
const FIELDCONST = 'diffusion.pre.content.revision.reviewers';
public function getHeraldFieldName() {
return pht('Differential reviewers');
}
public function getFieldGroupKey() {
return HeraldRelatedFieldGroup::FIELDGROUPKEY;
}
public function getHeraldFieldValue($object) {
$revision = $this->getAdapter()->getRevision();
if (!$revision) {
return array();
}
return $revision->getReviewerPHIDs();
}
protected function getHeraldFieldStandardType() {
return self::STANDARD_PHID_LIST;
}
protected function getDatasource() {
return new DifferentialReviewerDatasource();
}
}
| php | Apache-2.0 | 5720a38cfe95b00ca4be5016dd0d2f3195f4fa04 | 2026-01-04T15:03:23.651835Z | false |
phacility/phabricator | https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/diffusion/herald/DiffusionAuditorsHeraldAction.php | src/applications/diffusion/herald/DiffusionAuditorsHeraldAction.php | <?php
abstract class DiffusionAuditorsHeraldAction
extends HeraldAction {
const DO_AUTHORS = 'do.authors';
const DO_ADD_AUDITORS = 'do.add-auditors';
public function getActionGroupKey() {
return HeraldApplicationActionGroup::ACTIONGROUPKEY;
}
public function supportsObject($object) {
return ($object instanceof PhabricatorRepositoryCommit);
}
protected function applyAuditors(array $phids, HeraldRule $rule) {
$adapter = $this->getAdapter();
$object = $adapter->getObject();
$auditors = $object->getAudits();
// Don't try to add commit authors as auditors.
$authors = array();
foreach ($phids as $key => $phid) {
if ($phid == $object->getAuthorPHID()) {
$authors[] = $phid;
unset($phids[$key]);
}
}
if ($authors) {
$this->logEffect(self::DO_AUTHORS, $authors);
if (!$phids) {
return;
}
}
$current = array();
foreach ($auditors as $auditor) {
$current[] = $auditor->getAuditorPHID();
}
$allowed_types = array(
PhabricatorPeopleUserPHIDType::TYPECONST,
PhabricatorProjectProjectPHIDType::TYPECONST,
PhabricatorOwnersPackagePHIDType::TYPECONST,
);
$targets = $this->loadStandardTargets($phids, $allowed_types, $current);
if (!$targets) {
return;
}
$phids = array_fuse(array_keys($targets));
$xaction = $adapter->newTransaction()
->setTransactionType(DiffusionCommitAuditorsTransaction::TRANSACTIONTYPE)
->setNewValue(
array(
'+' => $phids,
));
$adapter->queueTransaction($xaction);
$this->logEffect(self::DO_ADD_AUDITORS, $phids);
}
protected function getActionEffectMap() {
return array(
self::DO_AUTHORS => array(
'icon' => 'fa-user',
'color' => 'grey',
'name' => pht('Commit Author'),
),
self::DO_ADD_AUDITORS => array(
'icon' => 'fa-user',
'color' => 'green',
'name' => pht('Added Auditors'),
),
);
}
protected function renderActionEffectDescription($type, $data) {
switch ($type) {
case self::DO_AUTHORS:
return pht(
'Declined to add commit author as auditor: %s.',
$this->renderHandleList($data));
case self::DO_ADD_AUDITORS:
return pht(
'Added %s auditor(s): %s.',
phutil_count($data),
$this->renderHandleList($data));
}
}
}
| php | Apache-2.0 | 5720a38cfe95b00ca4be5016dd0d2f3195f4fa04 | 2026-01-04T15:03:23.651835Z | false |
phacility/phabricator | https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/diffusion/herald/DiffusionPreCommitContentDiffContentRemovedHeraldField.php | src/applications/diffusion/herald/DiffusionPreCommitContentDiffContentRemovedHeraldField.php | <?php
final class DiffusionPreCommitContentDiffContentRemovedHeraldField
extends DiffusionPreCommitContentHeraldField {
const FIELDCONST = 'diffusion.pre.commit.diff.old';
public function getHeraldFieldName() {
return pht('Removed diff content');
}
public function getFieldGroupKey() {
return DiffusionChangeHeraldFieldGroup::FIELDGROUPKEY;
}
public function getHeraldFieldValue($object) {
return $this->getAdapter()->getDiffContent('-');
}
protected function getHeraldFieldStandardType() {
return self::STANDARD_TEXT_MAP;
}
}
| php | Apache-2.0 | 5720a38cfe95b00ca4be5016dd0d2f3195f4fa04 | 2026-01-04T15:03:23.651835Z | false |
phacility/phabricator | https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/diffusion/herald/DiffusionPreCommitContentAuthorHeraldField.php | src/applications/diffusion/herald/DiffusionPreCommitContentAuthorHeraldField.php | <?php
final class DiffusionPreCommitContentAuthorHeraldField
extends DiffusionPreCommitContentHeraldField {
const FIELDCONST = 'diffusion.pre.commit.author';
public function getHeraldFieldName() {
return pht('Author');
}
public function getHeraldFieldValue($object) {
return $this->getAdapter()->getAuthorPHID();
}
protected function getHeraldFieldStandardType() {
return self::STANDARD_PHID_NULLABLE;
}
protected function getDatasource() {
return new PhabricatorPeopleDatasource();
}
}
| php | Apache-2.0 | 5720a38cfe95b00ca4be5016dd0d2f3195f4fa04 | 2026-01-04T15:03:23.651835Z | false |
phacility/phabricator | https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/diffusion/herald/DiffusionPreCommitContentRevisionAcceptedHeraldField.php | src/applications/diffusion/herald/DiffusionPreCommitContentRevisionAcceptedHeraldField.php | <?php
final class DiffusionPreCommitContentRevisionAcceptedHeraldField
extends DiffusionPreCommitContentHeraldField {
const FIELDCONST = 'diffusion.pre.content.revision.accepted';
public function getHeraldFieldName() {
return pht('Accepted Differential revision');
}
public function getFieldGroupKey() {
return HeraldRelatedFieldGroup::FIELDGROUPKEY;
}
public function getHeraldFieldValue($object) {
$revision = $this->getAdapter()->getRevision();
if (!$revision) {
return null;
}
if ($revision->isAccepted()) {
return $revision->getPHID();
}
$was_accepted = DifferentialRevision::PROPERTY_CLOSED_FROM_ACCEPTED;
if ($revision->isPublished()) {
if ($revision->getProperty($was_accepted)) {
return $revision->getPHID();
}
}
return null;
}
protected function getHeraldFieldStandardType() {
return self::STANDARD_PHID_BOOL;
}
}
| php | Apache-2.0 | 5720a38cfe95b00ca4be5016dd0d2f3195f4fa04 | 2026-01-04T15:03:23.651835Z | false |
phacility/phabricator | https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/diffusion/herald/DiffusionCommitAuditorsHeraldField.php | src/applications/diffusion/herald/DiffusionCommitAuditorsHeraldField.php | <?php
final class DiffusionCommitAuditorsHeraldField
extends DiffusionCommitHeraldField {
const FIELDCONST = 'diffusion.commit.auditors';
public function getHeraldFieldName() {
return pht('Auditors');
}
public function getHeraldFieldValue($object) {
$viewer = PhabricatorUser::getOmnipotentUser();
$commit = id(new DiffusionCommitQuery())
->setViewer($viewer)
->withPHIDs(array($object->getPHID()))
->needAuditRequests(true)
->executeOne();
$audits = $commit->getAudits();
$phids = array();
foreach ($audits as $audit) {
if ($audit->isResigned()) {
continue;
}
$phids[] = $audit->getAuditorPHID();
}
return $phids;
}
protected function getHeraldFieldStandardType() {
return self::STANDARD_PHID_LIST;
}
protected function getDatasource() {
return new DiffusionAuditorDatasource();
}
}
| php | Apache-2.0 | 5720a38cfe95b00ca4be5016dd0d2f3195f4fa04 | 2026-01-04T15:03:23.651835Z | false |
phacility/phabricator | https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/diffusion/herald/DiffusionPreCommitContentRepositoryHeraldField.php | src/applications/diffusion/herald/DiffusionPreCommitContentRepositoryHeraldField.php | <?php
final class DiffusionPreCommitContentRepositoryHeraldField
extends DiffusionPreCommitContentHeraldField {
const FIELDCONST = 'diffusion.pre.content.repository';
public function getHeraldFieldName() {
return pht('Repository');
}
public function getHeraldFieldValue($object) {
return $this->getAdapter()->getHookEngine()->getRepository()->getPHID();
}
protected function getHeraldFieldStandardType() {
return HeraldField::STANDARD_PHID;
}
protected function getDatasource() {
return new DiffusionRepositoryDatasource();
}
}
| php | Apache-2.0 | 5720a38cfe95b00ca4be5016dd0d2f3195f4fa04 | 2026-01-04T15:03:23.651835Z | false |
phacility/phabricator | https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/diffusion/herald/DiffusionPreCommitRefNameHeraldField.php | src/applications/diffusion/herald/DiffusionPreCommitRefNameHeraldField.php | <?php
final class DiffusionPreCommitRefNameHeraldField
extends DiffusionPreCommitRefHeraldField {
const FIELDCONST = 'diffusion.pre.ref.name';
public function getHeraldFieldName() {
return pht('Ref name');
}
public function getHeraldFieldValue($object) {
return $object->getRefName();
}
protected function getHeraldFieldStandardType() {
return HeraldField::STANDARD_TEXT;
}
}
| php | Apache-2.0 | 5720a38cfe95b00ca4be5016dd0d2f3195f4fa04 | 2026-01-04T15:03:23.651835Z | false |
phacility/phabricator | https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/diffusion/herald/DiffusionCommitAuthorProjectsHeraldField.php | src/applications/diffusion/herald/DiffusionCommitAuthorProjectsHeraldField.php | <?php
final class DiffusionCommitAuthorProjectsHeraldField
extends DiffusionCommitHeraldField {
const FIELDCONST = 'diffusion.commit.author.projects';
public function getHeraldFieldName() {
return pht("Author's projects");
}
public function getHeraldFieldValue($object) {
$adapter = $this->getAdapter();
$viewer = $adapter->getViewer();
$author_phid = $adapter->getAuthorPHID();
if (!$author_phid) {
return array();
}
$projects = id(new PhabricatorProjectQuery())
->setViewer($viewer)
->withMemberPHIDs(array($author_phid))
->execute();
return mpull($projects, 'getPHID');
}
protected function getHeraldFieldStandardType() {
return self::STANDARD_PHID_LIST;
}
protected function getDatasource() {
return new PhabricatorProjectDatasource();
}
}
| php | Apache-2.0 | 5720a38cfe95b00ca4be5016dd0d2f3195f4fa04 | 2026-01-04T15:03:23.651835Z | false |
phacility/phabricator | https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/diffusion/herald/DiffusionPreCommitRefHeraldFieldGroup.php | src/applications/diffusion/herald/DiffusionPreCommitRefHeraldFieldGroup.php | <?php
final class DiffusionPreCommitRefHeraldFieldGroup extends HeraldFieldGroup {
const FIELDGROUPKEY = 'diffusion.ref';
public function getGroupLabel() {
return pht('Ref Fields');
}
protected function getGroupOrder() {
return 1000;
}
}
| php | Apache-2.0 | 5720a38cfe95b00ca4be5016dd0d2f3195f4fa04 | 2026-01-04T15:03:23.651835Z | false |
phacility/phabricator | https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/diffusion/herald/DiffusionCommitRevisionAcceptingReviewersHeraldField.php | src/applications/diffusion/herald/DiffusionCommitRevisionAcceptingReviewersHeraldField.php | <?php
final class DiffusionCommitRevisionAcceptingReviewersHeraldField
extends DiffusionCommitHeraldField {
const FIELDCONST = 'diffusion.commit.revision.accepting';
public function getHeraldFieldName() {
return pht('Accepting reviewers');
}
public function getFieldGroupKey() {
return HeraldRelatedFieldGroup::FIELDGROUPKEY;
}
public function getHeraldFieldValue($object) {
$revision = $this->getAdapter()->loadDifferentialRevision();
if (!$revision) {
return array();
}
$diff_phid = $revision->getActiveDiffPHID();
$reviewer_phids = array();
foreach ($revision->getReviewers() as $reviewer) {
if ($reviewer->isAccepted($diff_phid)) {
$reviewer_phids[] = $reviewer->getReviewerPHID();
}
}
return $reviewer_phids;
}
protected function getHeraldFieldStandardType() {
return self::STANDARD_PHID_LIST;
}
protected function getDatasource() {
return new DifferentialReviewerDatasource();
}
}
| php | Apache-2.0 | 5720a38cfe95b00ca4be5016dd0d2f3195f4fa04 | 2026-01-04T15:03:23.651835Z | false |
phacility/phabricator | https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/diffusion/herald/DiffusionPreCommitRefTypeHeraldField.php | src/applications/diffusion/herald/DiffusionPreCommitRefTypeHeraldField.php | <?php
final class DiffusionPreCommitRefTypeHeraldField
extends DiffusionPreCommitRefHeraldField {
const FIELDCONST = 'diffusion.pre.ref.type';
public function getHeraldFieldName() {
return pht('Ref type');
}
public function getHeraldFieldValue($object) {
return $object->getRefType();
}
public function getHeraldFieldConditions() {
return array(
HeraldAdapter::CONDITION_IS,
HeraldAdapter::CONDITION_IS_NOT,
);
}
public function getHeraldFieldValueType($condition) {
$types = array(
PhabricatorRepositoryPushLog::REFTYPE_BRANCH => pht('branch (git/hg)'),
PhabricatorRepositoryPushLog::REFTYPE_TAG => pht('tag (git)'),
PhabricatorRepositoryPushLog::REFTYPE_REF => pht('ref (git)'),
PhabricatorRepositoryPushLog::REFTYPE_BOOKMARK => pht('bookmark (hg)'),
);
return id(new HeraldSelectFieldValue())
->setKey(self::FIELDCONST)
->setOptions($types)
->setDefault(PhabricatorRepositoryPushLog::REFTYPE_BRANCH);
}
}
| php | Apache-2.0 | 5720a38cfe95b00ca4be5016dd0d2f3195f4fa04 | 2026-01-04T15:03:23.651835Z | false |
phacility/phabricator | https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/diffusion/herald/DiffusionPreCommitContentDiffContentHeraldField.php | src/applications/diffusion/herald/DiffusionPreCommitContentDiffContentHeraldField.php | <?php
final class DiffusionPreCommitContentDiffContentHeraldField
extends DiffusionPreCommitContentHeraldField {
const FIELDCONST = 'diffusion.pre.commit.diff.content';
public function getHeraldFieldName() {
return pht('Diff content');
}
public function getFieldGroupKey() {
return DiffusionChangeHeraldFieldGroup::FIELDGROUPKEY;
}
public function getHeraldFieldValue($object) {
return $this->getAdapter()->getDiffContent('*');
}
protected function getHeraldFieldStandardType() {
return self::STANDARD_TEXT_MAP;
}
}
| php | Apache-2.0 | 5720a38cfe95b00ca4be5016dd0d2f3195f4fa04 | 2026-01-04T15:03:23.651835Z | false |
phacility/phabricator | https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/diffusion/herald/HeraldPreCommitAdapter.php | src/applications/diffusion/herald/HeraldPreCommitAdapter.php | <?php
abstract class HeraldPreCommitAdapter extends HeraldAdapter {
private $log;
private $hookEngine;
abstract public function isPreCommitRefAdapter();
public function setPushLog(PhabricatorRepositoryPushLog $log) {
$this->log = $log;
return $this;
}
public function setHookEngine(DiffusionCommitHookEngine $engine) {
$this->hookEngine = $engine;
return $this;
}
public function getHookEngine() {
return $this->hookEngine;
}
public function getAdapterApplicationClass() {
return 'PhabricatorDiffusionApplication';
}
public function isTestAdapterForObject($object) {
return ($object instanceof PhabricatorRepositoryCommit);
}
public function canCreateTestAdapterForObject($object) {
return false;
}
public function getAdapterTestDescription() {
return pht(
'Commit hook events depend on repository state which is only available '.
'at push time, and can not be run in test mode.');
}
protected function initializeNewAdapter() {
$this->log = new PhabricatorRepositoryPushLog();
}
public function isSingleEventAdapter() {
return true;
}
public function getObject() {
return $this->log;
}
public function supportsRuleType($rule_type) {
switch ($rule_type) {
case HeraldRuleTypeConfig::RULE_TYPE_GLOBAL:
case HeraldRuleTypeConfig::RULE_TYPE_OBJECT:
case HeraldRuleTypeConfig::RULE_TYPE_PERSONAL:
return true;
default:
return false;
}
}
public function canTriggerOnObject($object) {
if ($object instanceof PhabricatorRepository) {
return true;
}
if ($object instanceof PhabricatorProject) {
return true;
}
return false;
}
public function explainValidTriggerObjects() {
return pht('This rule can trigger for **repositories** or **projects**.');
}
public function getTriggerObjectPHIDs() {
return array_merge(
array(
$this->hookEngine->getRepository()->getPHID(),
$this->getPHID(),
),
$this->hookEngine->getRepository()->getProjectPHIDs());
}
public function supportsWebhooks() {
return false;
}
}
| php | Apache-2.0 | 5720a38cfe95b00ca4be5016dd0d2f3195f4fa04 | 2026-01-04T15:03:23.651835Z | false |
phacility/phabricator | https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/diffusion/herald/DiffusionPreCommitContentRevisionHeraldField.php | src/applications/diffusion/herald/DiffusionPreCommitContentRevisionHeraldField.php | <?php
final class DiffusionPreCommitContentRevisionHeraldField
extends DiffusionPreCommitContentHeraldField {
const FIELDCONST = 'diffusion.pre.content.revision';
public function getHeraldFieldName() {
return pht('Differential revision');
}
public function getFieldGroupKey() {
return HeraldRelatedFieldGroup::FIELDGROUPKEY;
}
public function getHeraldFieldValue($object) {
$revision = $this->getAdapter()->getRevision();
if (!$revision) {
return null;
}
return $revision->getPHID();
}
protected function getHeraldFieldStandardType() {
return self::STANDARD_PHID_BOOL;
}
}
| php | Apache-2.0 | 5720a38cfe95b00ca4be5016dd0d2f3195f4fa04 | 2026-01-04T15:03:23.651835Z | false |
phacility/phabricator | https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/diffusion/herald/DiffusionPreCommitRefChangeHeraldField.php | src/applications/diffusion/herald/DiffusionPreCommitRefChangeHeraldField.php | <?php
final class DiffusionPreCommitRefChangeHeraldField
extends DiffusionPreCommitRefHeraldField {
const FIELDCONST = 'diffusion.pre.ref.change';
public function getHeraldFieldName() {
return pht('Ref change type');
}
public function getHeraldFieldValue($object) {
return $object->getChangeFlags();
}
public function getHeraldFieldConditions() {
return array(
HeraldAdapter::CONDITION_HAS_BIT,
HeraldAdapter::CONDITION_NOT_BIT,
);
}
public function getHeraldFieldValueType($condition) {
return id(new HeraldSelectFieldValue())
->setKey(self::FIELDCONST)
->setOptions(
PhabricatorRepositoryPushLog::getHeraldChangeFlagConditionOptions())
->setDefault(PhabricatorRepositoryPushLog::CHANGEFLAG_ADD);
}
}
| php | Apache-2.0 | 5720a38cfe95b00ca4be5016dd0d2f3195f4fa04 | 2026-01-04T15:03:23.651835Z | false |
phacility/phabricator | https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/diffusion/herald/DiffusionCommitMergeHeraldField.php | src/applications/diffusion/herald/DiffusionCommitMergeHeraldField.php | <?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;
}
}
| php | Apache-2.0 | 5720a38cfe95b00ca4be5016dd0d2f3195f4fa04 | 2026-01-04T15:03:23.651835Z | false |
phacility/phabricator | https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/diffusion/herald/DiffusionCommitDiffEnormousHeraldField.php | src/applications/diffusion/herald/DiffusionCommitDiffEnormousHeraldField.php | <?php
final class DiffusionCommitDiffEnormousHeraldField
extends DiffusionCommitHeraldField {
const FIELDCONST = 'diffusion.commit.enormous';
public function getHeraldFieldName() {
return pht('Change is enormous');
}
public function getFieldGroupKey() {
return DiffusionChangeHeraldFieldGroup::FIELDGROUPKEY;
}
public function getHeraldFieldValue($object) {
return $this->getAdapter()->isDiffEnormous();
}
protected function getHeraldFieldStandardType() {
return self::STANDARD_BOOL;
}
}
| php | Apache-2.0 | 5720a38cfe95b00ca4be5016dd0d2f3195f4fa04 | 2026-01-04T15:03:23.651835Z | false |
phacility/phabricator | https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/diffusion/herald/DiffusionPreCommitContentRepositoryProjectsHeraldField.php | src/applications/diffusion/herald/DiffusionPreCommitContentRepositoryProjectsHeraldField.php | <?php
final class DiffusionPreCommitContentRepositoryProjectsHeraldField
extends DiffusionPreCommitContentHeraldField {
const FIELDCONST = 'diffusion.pre.content.repository.projects';
public function getHeraldFieldName() {
return pht('Repository projects');
}
public function getHeraldFieldValue($object) {
return PhabricatorEdgeQuery::loadDestinationPHIDs(
$this->getAdapter()->getHookEngine()->getRepository()->getPHID(),
PhabricatorProjectObjectHasProjectEdgeType::EDGECONST);
}
protected function getHeraldFieldStandardType() {
return HeraldField::STANDARD_PHID_LIST;
}
protected function getDatasource() {
return new PhabricatorProjectDatasource();
}
}
| php | Apache-2.0 | 5720a38cfe95b00ca4be5016dd0d2f3195f4fa04 | 2026-01-04T15:03:23.651835Z | false |
phacility/phabricator | https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/diffusion/herald/DiffusionPreCommitUsesGitLFSHeraldField.php | src/applications/diffusion/herald/DiffusionPreCommitUsesGitLFSHeraldField.php | <?php
final class DiffusionPreCommitUsesGitLFSHeraldField
extends DiffusionPreCommitContentHeraldField {
const FIELDCONST = 'diffusion.pre.commit.git-lfs';
public function getHeraldFieldName() {
return pht('Commit uses Git LFS');
}
public function getFieldGroupKey() {
return DiffusionChangeHeraldFieldGroup::FIELDGROUPKEY;
}
public function getHeraldFieldValue($object) {
$map = $this->getAdapter()->getDiffContent('+');
// At the time of writing, all current Git LFS files begin with this
// line, verbatim:
//
// version https://git-lfs.github.com/spec/v1
//
// ...but we don't try to match the specific version here, in the hopes
// that this might also detect future versions.
$pattern = '(^version\s*https://git-lfs.github.com/spec/)i';
foreach ($map as $path => $content) {
if (preg_match($pattern, $content)) {
return true;
}
}
return false;
}
protected function getHeraldFieldStandardType() {
return self::STANDARD_BOOL;
}
}
| php | Apache-2.0 | 5720a38cfe95b00ca4be5016dd0d2f3195f4fa04 | 2026-01-04T15:03:23.651835Z | false |
phacility/phabricator | https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/diffusion/herald/DiffusionCommitAuthorHeraldField.php | src/applications/diffusion/herald/DiffusionCommitAuthorHeraldField.php | <?php
final class DiffusionCommitAuthorHeraldField
extends DiffusionCommitHeraldField {
const FIELDCONST = 'diffusion.commit.author';
public function getHeraldFieldName() {
return pht('Author');
}
public function getHeraldFieldValue($object) {
return $this->getAdapter()->getAuthorPHID();
}
protected function getHeraldFieldStandardType() {
return self::STANDARD_PHID_NULLABLE;
}
protected function getDatasource() {
return new PhabricatorPeopleDatasource();
}
}
| php | Apache-2.0 | 5720a38cfe95b00ca4be5016dd0d2f3195f4fa04 | 2026-01-04T15:03:23.651835Z | false |
phacility/phabricator | https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/diffusion/herald/DiffusionCommitRevisionSubscribersHeraldField.php | src/applications/diffusion/herald/DiffusionCommitRevisionSubscribersHeraldField.php | <?php
final class DiffusionCommitRevisionSubscribersHeraldField
extends DiffusionCommitHeraldField {
const FIELDCONST = 'diffusion.commit.revision.subscribers';
public function getHeraldFieldName() {
return pht('Differential subscribers');
}
public function getFieldGroupKey() {
return HeraldRelatedFieldGroup::FIELDGROUPKEY;
}
public function getHeraldFieldValue($object) {
$revision = $this->getAdapter()->loadDifferentialRevision();
if (!$revision) {
return array();
}
$phid = $revision->getPHID();
return PhabricatorSubscribersQuery::loadSubscribersForPHID($phid);
}
protected function getHeraldFieldStandardType() {
return self::STANDARD_PHID_LIST;
}
protected function getDatasource() {
return new PhabricatorProjectOrUserDatasource();
}
}
| php | Apache-2.0 | 5720a38cfe95b00ca4be5016dd0d2f3195f4fa04 | 2026-01-04T15:03:23.651835Z | false |
phacility/phabricator | https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/diffusion/herald/DiffusionPreCommitContentCommitterRawHeraldField.php | src/applications/diffusion/herald/DiffusionPreCommitContentCommitterRawHeraldField.php | <?php
final class DiffusionPreCommitContentCommitterRawHeraldField
extends DiffusionPreCommitContentHeraldField {
const FIELDCONST = 'diffusion.pre.commit.committer.raw';
public function getHeraldFieldName() {
return pht('Raw Committer');
}
public function getHeraldFieldValue($object) {
return $this->getAdapter()->getCommitterRaw();
}
protected function getHeraldFieldStandardType() {
return self::STANDARD_TEXT;
}
}
| php | Apache-2.0 | 5720a38cfe95b00ca4be5016dd0d2f3195f4fa04 | 2026-01-04T15:03:23.651835Z | false |
phacility/phabricator | https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/diffusion/herald/DiffusionPreCommitContentRevisionAcceptingReviewersHeraldField.php | src/applications/diffusion/herald/DiffusionPreCommitContentRevisionAcceptingReviewersHeraldField.php | <?php
final class DiffusionPreCommitContentRevisionAcceptingReviewersHeraldField
extends DiffusionPreCommitContentHeraldField {
const FIELDCONST = 'diffusion.pre.content.revision.accepting';
public function getHeraldFieldName() {
return pht('Accepting reviewers');
}
public function getFieldGroupKey() {
return HeraldRelatedFieldGroup::FIELDGROUPKEY;
}
public function getHeraldFieldValue($object) {
$revision = $this->getAdapter()->getRevision();
if (!$revision) {
return array();
}
$diff_phid = $revision->getActiveDiffPHID();
$reviewer_phids = array();
foreach ($revision->getReviewers() as $reviewer) {
if ($reviewer->isAccepted($diff_phid)) {
$reviewer_phids[] = $reviewer->getReviewerPHID();
}
}
return $reviewer_phids;
}
protected function getHeraldFieldStandardType() {
return self::STANDARD_PHID_LIST;
}
protected function getDatasource() {
return new DifferentialReviewerDatasource();
}
}
| php | Apache-2.0 | 5720a38cfe95b00ca4be5016dd0d2f3195f4fa04 | 2026-01-04T15:03:23.651835Z | false |
phacility/phabricator | https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/diffusion/herald/DiffusionPreCommitRefHeraldField.php | src/applications/diffusion/herald/DiffusionPreCommitRefHeraldField.php | <?php
abstract class DiffusionPreCommitRefHeraldField extends HeraldField {
public function supportsObject($object) {
if (!($object instanceof PhabricatorRepositoryPushLog)) {
return false;
}
if (!$this->getAdapter()->isPreCommitRefAdapter()) {
return false;
}
return true;
}
public function getFieldGroupKey() {
return DiffusionPreCommitRefHeraldFieldGroup::FIELDGROUPKEY;
}
}
| php | Apache-2.0 | 5720a38cfe95b00ca4be5016dd0d2f3195f4fa04 | 2026-01-04T15:03:23.651835Z | false |
phacility/phabricator | https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/diffusion/herald/DiffusionPreCommitContentAffectedFilesHeraldField.php | src/applications/diffusion/herald/DiffusionPreCommitContentAffectedFilesHeraldField.php | <?php
final class DiffusionPreCommitContentAffectedFilesHeraldField
extends DiffusionPreCommitContentHeraldField {
const FIELDCONST = 'diffusion.pre.commit.affected';
public function getHeraldFieldName() {
return pht('Affected files');
}
public function getFieldGroupKey() {
return DiffusionChangeHeraldFieldGroup::FIELDGROUPKEY;
}
public function getHeraldFieldValue($object) {
return $this->getAdapter()->getDiffContent('name');
}
protected function getHeraldFieldStandardType() {
return self::STANDARD_TEXT_LIST;
}
}
| php | Apache-2.0 | 5720a38cfe95b00ca4be5016dd0d2f3195f4fa04 | 2026-01-04T15:03:23.651835Z | false |
phacility/phabricator | https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/diffusion/herald/DiffusionPreCommitRefPusherHeraldField.php | src/applications/diffusion/herald/DiffusionPreCommitRefPusherHeraldField.php | <?php
final class DiffusionPreCommitRefPusherHeraldField
extends DiffusionPreCommitRefHeraldField {
const FIELDCONST = 'diffusion.pre.ref.pusher';
public function getHeraldFieldName() {
return pht('Pusher');
}
public function getHeraldFieldValue($object) {
return $this->getAdapter()->getHookEngine()->getViewer()->getPHID();
}
protected function getHeraldFieldStandardType() {
return HeraldField::STANDARD_PHID;
}
protected function getDatasource() {
return new PhabricatorPeopleDatasource();
}
}
| php | Apache-2.0 | 5720a38cfe95b00ca4be5016dd0d2f3195f4fa04 | 2026-01-04T15:03:23.651835Z | false |
phacility/phabricator | https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/diffusion/config/PhabricatorDiffusionConfigOptions.php | src/applications/diffusion/config/PhabricatorDiffusionConfigOptions.php | <?php
final class PhabricatorDiffusionConfigOptions
extends PhabricatorApplicationConfigOptions {
public function getName() {
return pht('Diffusion');
}
public function getDescription() {
return pht('Configure Diffusion repository browsing.');
}
public function getIcon() {
return 'fa-code';
}
public function getGroup() {
return 'apps';
}
public function getOptions() {
$custom_field_type = 'custom:PhabricatorCustomFieldConfigOptionType';
$fields = array(
new PhabricatorCommitRepositoryField(),
new PhabricatorCommitBranchesField(),
new PhabricatorCommitTagsField(),
new PhabricatorCommitMergedCommitsField(),
);
$default_fields = array();
foreach ($fields as $field) {
$default_fields[$field->getFieldKey()] = array(
'disabled' => $field->shouldDisableByDefault(),
);
}
return array(
$this->newOption(
'metamta.diffusion.attach-patches',
'bool',
false)
->setBoolOptions(
array(
pht('Attach Patches'),
pht('Do Not Attach Patches'),
))
->setDescription(
pht(
'Set this to true if you want patches to be attached to commit '.
'notifications from Diffusion.')),
$this->newOption('metamta.diffusion.inline-patches', 'int', 0)
->setSummary(pht('Include patches in Diffusion mail as body text.'))
->setDescription(
pht(
'To include patches in Diffusion email bodies, set this to a '.
'positive integer. Patches will be inlined if they are at most '.
'that many lines. By default, patches are not inlined.')),
$this->newOption('metamta.diffusion.byte-limit', 'int', 1024 * 1024)
->setDescription(pht('Hard byte limit on including patches in email.')),
$this->newOption('metamta.diffusion.time-limit', 'int', 60)
->setDescription(pht('Hard time limit on generating patches.')),
$this->newOption(
'audit.can-author-close-audit',
'bool',
false)
->setBoolOptions(
array(
pht('Enable Self-Accept'),
pht('Disable Self-Accept'),
))
->setDescription(
pht(
'Allows the author of a commit to be an auditor and accept their '.
'own commits. Note that this behavior is different from the '.
'behavior implied by the name of the option: long ago, it did '.
'something else.')),
$this->newOption('bugtraq.url', 'string', null)
->addExample('https://bugs.php.net/%BUGID%', pht('PHP bugs'))
->addExample('/%BUGID%', pht('Local Maniphest URL'))
->setDescription(
pht(
'URL of external bug tracker used by Diffusion. %s will be '.
'substituted by the bug ID.',
'%BUGID%')),
$this->newOption('bugtraq.logregex', 'list<regex>', array())
->addExample(array('/\B#([1-9]\d*)\b/'), pht('Issue #123'))
->addExample(
array('/[Ii]ssues?:?(\s*,?\s*#\d+)+/', '/(\d+)/'),
pht('Issue #123, #456'))
->addExample(array('/(?<!#)\b(T[1-9]\d*)\b/'), pht('Task T123'))
->addExample('/[A-Z]{2,}-\d+/', pht('JIRA-1234'))
->setDescription(
pht(
'Regular expression to link external bug tracker. See '.
'http://tortoisesvn.net/docs/release/TortoiseSVN_en/'.
'tsvn-dug-bugtracker.html for further explanation.')),
$this->newOption('diffusion.allow-http-auth', 'bool', false)
->setBoolOptions(
array(
pht('Allow HTTP Basic Auth'),
pht('Disallow HTTP Basic Auth'),
))
->setSummary(pht('Enable HTTP Basic Auth for repositories.'))
->setDescription(
pht(
"This server can serve repositories over HTTP, using HTTP basic ".
"auth.\n\n".
"Because HTTP basic auth is less secure than SSH auth, it is ".
"disabled by default. You can enable it here if you'd like to use ".
"it anyway. There's nothing fundamentally insecure about it as ".
"long as this server uses HTTPS, but it presents a much lower ".
"barrier to attackers than SSH does.\n\n".
"Consider using SSH for authenticated access to repositories ".
"instead of HTTP.")),
$this->newOption('diffusion.allow-git-lfs', 'bool', false)
->setBoolOptions(
array(
pht('Allow Git LFS'),
pht('Disallow Git LFS'),
))
->setLocked(true)
->setSummary(pht('Allow Git Large File Storage (LFS).'))
->setDescription(
pht(
'This server supports Git LFS, a Git extension for storing large '.
'files alongside a repository. Activate this setting to allow '.
'the extension to store file data.')),
$this->newOption('diffusion.ssh-user', 'string', null)
->setLocked(true)
->setSummary(pht('Login username for SSH connections to repositories.'))
->setDescription(
pht(
'When constructing clone URIs to show to users, Diffusion will '.
'fill in this login username. If you have configured a VCS user '.
'like `git`, you should provide it here.')),
$this->newOption('diffusion.ssh-port', 'int', null)
->setLocked(true)
->setSummary(pht('Port for SSH connections to repositories.'))
->setDescription(
pht(
'When constructing clone URIs to show to users, Diffusion by '.
'default will not display a port assuming the default for your '.
'VCS. Explicitly declare when running on a non-standard port.')),
$this->newOption('diffusion.ssh-host', 'string', null)
->setLocked(true)
->setSummary(pht('Host for SSH connections to repositories.'))
->setDescription(
pht(
'If you accept SSH traffic on a different host from web traffic '.
'(for example, if you use different SSH and web load balancers), '.
'you can set the SSH hostname here. This is an advanced option.')),
$this->newOption('diffusion.fields', $custom_field_type, $default_fields)
->setCustomData(
id(new PhabricatorRepositoryCommit())
->getCustomFieldBaseClass())
->setDescription(
pht('Select and reorder Diffusion fields.')),
);
}
}
| php | Apache-2.0 | 5720a38cfe95b00ca4be5016dd0d2f3195f4fa04 | 2026-01-04T15:03:23.651835Z | false |
phacility/phabricator | https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/diffusion/conduit/DiffusionGetLintMessagesConduitAPIMethod.php | src/applications/diffusion/conduit/DiffusionGetLintMessagesConduitAPIMethod.php | <?php
final class DiffusionGetLintMessagesConduitAPIMethod
extends DiffusionConduitAPIMethod {
public function getAPIMethodName() {
return 'diffusion.getlintmessages';
}
public function getMethodStatus() {
return self::METHOD_STATUS_UNSTABLE;
}
public function getMethodDescription() {
return pht('Get lint messages for existing code.');
}
protected function defineParamTypes() {
return array(
'repositoryPHID' => 'required phid',
'branch' => 'required string',
'commit' => 'optional string',
'files' => 'required list<string>',
);
}
protected function defineReturnType() {
return 'list<dict>';
}
protected function execute(ConduitAPIRequest $request) {
$viewer = $request->getUser();
$repository_phid = $request->getValue('repositoryPHID');
$repository = id(new PhabricatorRepositoryQuery())
->setViewer($viewer)
->withPHIDs(array($repository_phid))
->executeOne();
if (!$repository) {
throw new Exception(
pht('No repository exists with PHID "%s".', $repository_phid));
}
$branch_name = $request->getValue('branch');
if ($branch_name == '') {
$repository = id(new PhabricatorRepositoryQuery())
->setViewer($request->getUser())
->withIDs(array($repository->getID()))
->executeOne();
$branch_name = $repository->getDefaultArcanistBranch();
}
$branch = id(new PhabricatorRepositoryBranch())->loadOneWhere(
'repositoryID = %d AND name = %s',
$repository->getID(),
$branch_name);
if (!$branch || !$branch->getLintCommit()) {
return array();
}
$lint_messages = queryfx_all(
$branch->establishConnection('r'),
'SELECT path, line, code FROM %T WHERE branchID = %d AND path IN (%Ls)',
PhabricatorRepository::TABLE_LINTMESSAGE,
$branch->getID(),
$request->getValue('files'));
// TODO: Compare commit identifiers of individual files like in
// DiffusionBrowseFileController::loadLintMessages().
return $lint_messages;
}
}
| php | Apache-2.0 | 5720a38cfe95b00ca4be5016dd0d2f3195f4fa04 | 2026-01-04T15:03:23.651835Z | false |
phacility/phabricator | https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/diffusion/conduit/DiffusionRawDiffQueryConduitAPIMethod.php | src/applications/diffusion/conduit/DiffusionRawDiffQueryConduitAPIMethod.php | <?php
final class DiffusionRawDiffQueryConduitAPIMethod
extends DiffusionQueryConduitAPIMethod {
public function getAPIMethodName() {
return 'diffusion.rawdiffquery';
}
public function getMethodDescription() {
return pht(
'Get raw diff information from a repository for a specific commit at an '.
'(optional) path.');
}
protected function defineReturnType() {
return 'string';
}
protected function defineCustomParamTypes() {
return array(
'commit' => 'required string',
'path' => 'optional string',
'linesOfContext' => 'optional int',
'againstCommit' => 'optional string',
) + DiffusionFileFutureQuery::getConduitParameters();
}
protected function getResult(ConduitAPIRequest $request) {
$drequest = $this->getDiffusionRequest();
$query = DiffusionRawDiffQuery::newFromDiffusionRequest($drequest);
$lines_of_context = $request->getValue('linesOfContext');
if ($lines_of_context !== null) {
$query->setLinesOfContext($lines_of_context);
}
$against_commit = $request->getValue('againstCommit');
if ($against_commit !== null) {
$query->setAgainstCommit($against_commit);
}
return $query->respondToConduitRequest($request);
}
}
| php | Apache-2.0 | 5720a38cfe95b00ca4be5016dd0d2f3195f4fa04 | 2026-01-04T15:03:23.651835Z | false |
phacility/phabricator | https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/diffusion/conduit/DiffusionBlameConduitAPIMethod.php | src/applications/diffusion/conduit/DiffusionBlameConduitAPIMethod.php | <?php
final class DiffusionBlameConduitAPIMethod
extends DiffusionQueryConduitAPIMethod {
public function getAPIMethodName() {
return 'diffusion.blame';
}
public function getMethodDescription() {
return pht('Get blame information for a list of paths.');
}
protected function defineReturnType() {
return 'map<string, wild>';
}
protected function defineCustomParamTypes() {
return array(
'paths' => 'required list<string>',
'commit' => 'required string',
'timeout' => 'optional int',
);
}
protected function getResult(ConduitAPIRequest $request) {
$drequest = $this->getDiffusionRequest();
$paths = $request->getValue('paths');
$blame_query = DiffusionBlameQuery::newFromDiffusionRequest($drequest)
->setPaths($paths);
$timeout = $request->getValue('timeout');
if ($timeout) {
$blame_query->setTimeout($timeout);
}
$blame = $blame_query->execute();
return $blame;
}
}
| php | Apache-2.0 | 5720a38cfe95b00ca4be5016dd0d2f3195f4fa04 | 2026-01-04T15:03:23.651835Z | false |
phacility/phabricator | https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/diffusion/conduit/DiffusionBrowseQueryConduitAPIMethod.php | src/applications/diffusion/conduit/DiffusionBrowseQueryConduitAPIMethod.php | <?php
final class DiffusionBrowseQueryConduitAPIMethod
extends DiffusionQueryConduitAPIMethod {
public function getAPIMethodName() {
return 'diffusion.browsequery';
}
public function getMethodDescription() {
return pht(
'File(s) information for a repository at an (optional) path and '.
'(optional) commit.');
}
protected function defineReturnType() {
return 'array';
}
protected function defineCustomParamTypes() {
return array(
'path' => 'optional string',
'commit' => 'optional string',
'needValidityOnly' => 'optional bool',
'limit' => 'optional int',
'offset' => 'optional int',
);
}
protected function getResult(ConduitAPIRequest $request) {
$result = parent::getResult($request);
return $result->toDictionary();
}
protected function getGitResult(ConduitAPIRequest $request) {
$drequest = $this->getDiffusionRequest();
$repository = $drequest->getRepository();
$path = $request->getValue('path');
if ($path === null || !strlen($path) || $path === '/') {
$path = null;
}
$commit = $request->getValue('commit');
$offset = (int)$request->getValue('offset');
$limit = (int)$request->getValue('limit');
$result = $this->getEmptyResultSet();
if ($path === null) {
// Fast path to improve the performance of the repository view; we know
// the root is always a tree at any commit and always exists.
$path_type = 'tree';
} else {
try {
list($stdout) = $repository->execxLocalCommand(
'cat-file -t -- %s',
sprintf('%s:%s', $commit, $path));
$path_type = trim($stdout);
} catch (CommandException $e) {
// The "cat-file" command may fail if the path legitimately does not
// exist, but it may also fail if the path is a submodule. This can
// produce either "Not a valid object name" or "could not get object
// info".
// To detect if we have a submodule, use `git ls-tree`. If the path
// is a submodule, we'll get a "160000" mode mask with type "commit".
list($sub_err, $sub_stdout) = $repository->execLocalCommand(
'ls-tree %s -- %s',
gitsprintf('%s', $commit),
$path);
if (!$sub_err) {
// If the path failed "cat-file" but "ls-tree" worked, we assume it
// must be a submodule. If it is, the output will look something
// like this:
//
// 160000 commit <hash> <path>
//
// We make sure it has the 160000 mode mask to confirm that it's
// definitely a submodule.
$mode = (int)$sub_stdout;
if ($mode & 160000) {
$submodule_reason = DiffusionBrowseResultSet::REASON_IS_SUBMODULE;
$result
->setReasonForEmptyResultSet($submodule_reason);
return $result;
}
}
$stderr = $e->getStderr();
if (preg_match('/^fatal: Not a valid object name/', $stderr)) {
// Grab two logs, since the first one is when the object was deleted.
list($stdout) = $repository->execxLocalCommand(
'log -n2 %s %s -- %s',
'--format=%H',
gitsprintf('%s', $commit),
$path);
$stdout = trim($stdout);
if ($stdout) {
$commits = explode("\n", $stdout);
$result
->setReasonForEmptyResultSet(
DiffusionBrowseResultSet::REASON_IS_DELETED)
->setDeletedAtCommit(idx($commits, 0))
->setExistedAtCommit(idx($commits, 1));
return $result;
}
$result->setReasonForEmptyResultSet(
DiffusionBrowseResultSet::REASON_IS_NONEXISTENT);
return $result;
} else {
throw $e;
}
}
}
if ($path_type === 'blob') {
$result->setReasonForEmptyResultSet(
DiffusionBrowseResultSet::REASON_IS_FILE);
return $result;
}
$result->setIsValidResults(true);
if ($this->shouldOnlyTestValidity($request)) {
return $result;
}
if ($path === null) {
list($stdout) = $repository->execxLocalCommand(
'ls-tree -z -l %s --',
gitsprintf('%s', $commit));
} else {
if ($path_type === 'tree') {
$path = rtrim($path, '/').'/';
} else {
$path = rtrim($path, '/');
}
list($stdout) = $repository->execxLocalCommand(
'ls-tree -z -l %s -- %s',
gitsprintf('%s', $commit),
$path);
}
$submodules = array();
$count = 0;
$results = array();
$lines = empty($stdout)
? array()
: explode("\0", rtrim($stdout));
foreach ($lines as $line) {
// NOTE: Limit to 5 components so we parse filenames with spaces in them
// correctly.
// NOTE: The output uses a mixture of tabs and one-or-more spaces to
// delimit fields.
$parts = preg_split('/\s+/', $line, 5);
if (count($parts) < 5) {
throw new Exception(
pht(
'Expected "<mode> <type> <hash> <size>\t<name>", for ls-tree of '.
'"%s:%s", got: %s',
$commit,
$path,
$line));
}
list($mode, $type, $hash, $size, $full_path) = $parts;
$path_result = new DiffusionRepositoryPath();
if ($type == 'tree') {
$file_type = DifferentialChangeType::FILE_DIRECTORY;
} else if ($type == 'commit') {
$file_type = DifferentialChangeType::FILE_SUBMODULE;
$submodules[] = $path_result;
} else {
$mode = intval($mode, 8);
if (($mode & 0120000) == 0120000) {
$file_type = DifferentialChangeType::FILE_SYMLINK;
} else {
$file_type = DifferentialChangeType::FILE_NORMAL;
}
}
if ($path === null) {
$local_path = $full_path;
} else {
$local_path = basename($full_path);
}
$path_result->setFullPath($full_path);
$path_result->setPath($local_path);
$path_result->setHash($hash);
$path_result->setFileType($file_type);
$path_result->setFileSize($size);
if ($count >= $offset) {
$results[] = $path_result;
}
$count++;
if ($limit && $count >= ($offset + $limit)) {
break;
}
}
// If we identified submodules, lookup the module info at this commit to
// find their source URIs.
if ($submodules) {
// NOTE: We need to read the file out of git and write it to a temporary
// location because "git config -f" doesn't accept a "commit:path"-style
// argument.
// NOTE: This file may not exist, e.g. because the commit author removed
// it when they added the submodule. See T1448. If it's not present, just
// show the submodule without enriching it. If ".gitmodules" was removed
// it seems to partially break submodules, but the repository as a whole
// continues to work fine and we've seen at least two cases of this in
// the wild.
list($err, $contents) = $repository->execLocalCommand(
'cat-file blob -- %s:.gitmodules',
$commit);
if (!$err) {
// NOTE: After T13673, the user executing "git" may not be the same
// as the user this process is running as (usually the webserver user),
// so we can't reliably use a temporary file: the daemon user may not
// be able to use it.
// Use "--file -" to read from stdin instead. If this fails in some
// older versions of Git, we could exempt this particular command from
// sudoing to the daemon user.
$future = $repository->getLocalCommandFuture('config -l --file - --');
$future->write($contents);
list($module_info) = $future->resolvex();
$dict = array();
$lines = explode("\n", trim($module_info));
foreach ($lines as $line) {
list($key, $value) = explode('=', $line, 2);
$parts = explode('.', $key);
$dict[$key] = $value;
}
foreach ($submodules as $submodule_path) {
$full_path = $submodule_path->getFullPath();
$key = 'submodule.'.$full_path.'.url';
if (isset($dict[$key])) {
$submodule_path->setExternalURI($dict[$key]);
}
}
}
}
return $result->setPaths($results);
}
protected function getMercurialResult(ConduitAPIRequest $request) {
$drequest = $this->getDiffusionRequest();
$repository = $drequest->getRepository();
$path = $request->getValue('path');
$commit = $request->getValue('commit');
$offset = (int)$request->getValue('offset');
$limit = (int)$request->getValue('limit');
$result = $this->getEmptyResultSet();
$entire_manifest = id(new DiffusionLowLevelMercurialPathsQuery())
->setRepository($repository)
->withCommit($commit)
->withPath($path)
->execute();
$results = array();
if ($path !== null) {
$match_against = trim($path, '/');
$match_len = strlen($match_against);
} else {
$match_against = '';
$match_len = 0;
}
// For the root, don't trim. For other paths, trim the "/" after we match.
// We need this because Mercurial's canonical paths have no leading "/",
// but ours do.
$trim_len = $match_len ? $match_len + 1 : 0;
$count = 0;
foreach ($entire_manifest as $path) {
if (strncmp($path, $match_against, $match_len)) {
continue;
}
if ($path === null || !strlen($path)) {
continue;
}
$remainder = substr($path, $trim_len);
if (!strlen($remainder)) {
// There is a file with this exact name in the manifest, so clearly
// it's a file.
$result->setReasonForEmptyResultSet(
DiffusionBrowseResultSet::REASON_IS_FILE);
return $result;
}
$parts = explode('/', $remainder);
$name = reset($parts);
// If we've already seen this path component, we're looking at a file
// inside a directory we already processed. Just move on.
if (isset($results[$name])) {
continue;
}
if (count($parts) == 1) {
$type = DifferentialChangeType::FILE_NORMAL;
} else {
$type = DifferentialChangeType::FILE_DIRECTORY;
}
if ($count >= $offset) {
$results[$name] = $type;
}
$count++;
if ($limit && ($count >= ($offset + $limit))) {
break;
}
}
foreach ($results as $key => $type) {
$path_result = new DiffusionRepositoryPath();
$path_result->setPath($key);
$path_result->setFileType($type);
$path_result->setFullPath(ltrim($match_against.'/', '/').$key);
$results[$key] = $path_result;
}
$valid_results = true;
if (empty($results)) {
// TODO: Detect "deleted" by issuing "hg log"?
$result->setReasonForEmptyResultSet(
DiffusionBrowseResultSet::REASON_IS_NONEXISTENT);
$valid_results = false;
}
return $result
->setPaths($results)
->setIsValidResults($valid_results);
}
protected function getSVNResult(ConduitAPIRequest $request) {
$drequest = $this->getDiffusionRequest();
$repository = $drequest->getRepository();
$path = $request->getValue('path');
$commit = $request->getValue('commit');
$offset = (int)$request->getValue('offset');
$limit = (int)$request->getValue('limit');
$result = $this->getEmptyResultSet();
$subpath = $repository->getDetail('svn-subpath');
if ($subpath && strncmp($subpath, $path, strlen($subpath))) {
// If we have a subpath and the path isn't a child of it, it (almost
// certainly) won't exist since we don't track commits which affect
// it. (Even if it exists, return a consistent result.)
$result->setReasonForEmptyResultSet(
DiffusionBrowseResultSet::REASON_IS_UNTRACKED_PARENT);
return $result;
}
$conn_r = $repository->establishConnection('r');
$parent_path = DiffusionPathIDQuery::getParentPath($path);
$path_query = new DiffusionPathIDQuery(
array(
$path,
$parent_path,
));
$path_map = $path_query->loadPathIDs();
$path_id = $path_map[$path];
$parent_path_id = $path_map[$parent_path];
if (empty($path_id)) {
$result->setReasonForEmptyResultSet(
DiffusionBrowseResultSet::REASON_IS_NONEXISTENT);
return $result;
}
if ($commit) {
$slice_clause = qsprintf($conn_r, 'AND svnCommit <= %d', $commit);
} else {
$slice_clause = qsprintf($conn_r, '');
}
$index = queryfx_all(
$conn_r,
'SELECT pathID, max(svnCommit) maxCommit FROM %T WHERE
repositoryID = %d AND parentID = %d
%Q GROUP BY pathID',
PhabricatorRepository::TABLE_FILESYSTEM,
$repository->getID(),
$path_id,
$slice_clause);
if (!$index) {
if ($path == '/') {
$result->setReasonForEmptyResultSet(
DiffusionBrowseResultSet::REASON_IS_EMPTY);
} else {
// NOTE: The parent path ID is included so this query can take
// advantage of the table's primary key; it is uniquely determined by
// the pathID but if we don't do the lookup ourselves MySQL doesn't have
// the information it needs to avoid a table scan.
$reasons = queryfx_all(
$conn_r,
'SELECT * FROM %T WHERE repositoryID = %d
AND parentID = %d
AND pathID = %d
%Q ORDER BY svnCommit DESC LIMIT 2',
PhabricatorRepository::TABLE_FILESYSTEM,
$repository->getID(),
$parent_path_id,
$path_id,
$slice_clause);
$reason = reset($reasons);
if (!$reason) {
$result->setReasonForEmptyResultSet(
DiffusionBrowseResultSet::REASON_IS_NONEXISTENT);
} else {
$file_type = $reason['fileType'];
if (empty($reason['existed'])) {
$result->setReasonForEmptyResultSet(
DiffusionBrowseResultSet::REASON_IS_DELETED);
$result->setDeletedAtCommit($reason['svnCommit']);
if (!empty($reasons[1])) {
$result->setExistedAtCommit($reasons[1]['svnCommit']);
}
} else if ($file_type == DifferentialChangeType::FILE_DIRECTORY) {
$result->setReasonForEmptyResultSet(
DiffusionBrowseResultSet::REASON_IS_EMPTY);
} else {
$result->setReasonForEmptyResultSet(
DiffusionBrowseResultSet::REASON_IS_FILE);
}
}
}
return $result;
}
$result->setIsValidResults(true);
if ($this->shouldOnlyTestValidity($request)) {
return $result;
}
$sql = array();
foreach ($index as $row) {
$sql[] = qsprintf(
$conn_r,
'(pathID = %d AND svnCommit = %d)',
$row['pathID'],
$row['maxCommit']);
}
$browse = queryfx_all(
$conn_r,
'SELECT *, p.path pathName
FROM %T f JOIN %T p ON f.pathID = p.id
WHERE repositoryID = %d
AND parentID = %d
AND existed = 1
AND (%LO)
ORDER BY pathName',
PhabricatorRepository::TABLE_FILESYSTEM,
PhabricatorRepository::TABLE_PATH,
$repository->getID(),
$path_id,
$sql);
$loadable_commits = array();
foreach ($browse as $key => $file) {
// We need to strip out directories because we don't store last-modified
// in the filesystem table.
if ($file['fileType'] != DifferentialChangeType::FILE_DIRECTORY) {
$loadable_commits[] = $file['svnCommit'];
$browse[$key]['hasCommit'] = true;
}
}
$commits = array();
$commit_data = array();
if ($loadable_commits) {
// NOTE: Even though these are integers, use '%Ls' because MySQL doesn't
// use the second part of the key otherwise!
$commits = id(new PhabricatorRepositoryCommit())->loadAllWhere(
'repositoryID = %d AND commitIdentifier IN (%Ls)',
$repository->getID(),
$loadable_commits);
$commits = mpull($commits, null, 'getCommitIdentifier');
if ($commits) {
$commit_data = id(new PhabricatorRepositoryCommitData())->loadAllWhere(
'commitID in (%Ld)',
mpull($commits, 'getID'));
$commit_data = mpull($commit_data, null, 'getCommitID');
} else {
$commit_data = array();
}
}
$path_normal = DiffusionPathIDQuery::normalizePath($path);
$results = array();
$count = 0;
foreach ($browse as $file) {
$full_path = $file['pathName'];
$file_path = ltrim(substr($full_path, strlen($path_normal)), '/');
$full_path = ltrim($full_path, '/');
$result_path = new DiffusionRepositoryPath();
$result_path->setPath($file_path);
$result_path->setFullPath($full_path);
$result_path->setFileType($file['fileType']);
if (!empty($file['hasCommit'])) {
$commit = idx($commits, $file['svnCommit']);
if ($commit) {
$data = idx($commit_data, $commit->getID());
$result_path->setLastModifiedCommit($commit);
$result_path->setLastCommitData($data);
}
}
if ($count >= $offset) {
$results[] = $result_path;
}
$count++;
if ($limit && ($count >= ($offset + $limit))) {
break;
}
}
if (empty($results)) {
$result->setReasonForEmptyResultSet(
DiffusionBrowseResultSet::REASON_IS_EMPTY);
}
return $result->setPaths($results);
}
private function getEmptyResultSet() {
return id(new DiffusionBrowseResultSet())
->setPaths(array())
->setReasonForEmptyResultSet(null)
->setIsValidResults(false);
}
private function shouldOnlyTestValidity(ConduitAPIRequest $request) {
return $request->getValue('needValidityOnly', false);
}
}
| php | Apache-2.0 | 5720a38cfe95b00ca4be5016dd0d2f3195f4fa04 | 2026-01-04T15:03:23.651835Z | false |
phacility/phabricator | https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/diffusion/conduit/DiffusionQueryPathsConduitAPIMethod.php | src/applications/diffusion/conduit/DiffusionQueryPathsConduitAPIMethod.php | <?php
final class DiffusionQueryPathsConduitAPIMethod
extends DiffusionQueryConduitAPIMethod {
public function getAPIMethodName() {
return 'diffusion.querypaths';
}
public function getMethodDescription() {
return pht('Filename search on a repository.');
}
protected function defineReturnType() {
return 'list<string>';
}
protected function defineCustomParamTypes() {
return array(
'path' => 'required string',
'commit' => 'required string',
'pattern' => 'optional string',
'limit' => 'optional int',
'offset' => 'optional int',
);
}
protected function getResult(ConduitAPIRequest $request) {
$results = parent::getResult($request);
$offset = $request->getValue('offset');
return array_slice($results, $offset);
}
protected function getGitResult(ConduitAPIRequest $request) {
$drequest = $this->getDiffusionRequest();
$path = $drequest->getPath();
$commit = $request->getValue('commit');
$repository = $drequest->getRepository();
// Recent versions of Git don't work if you pass the empty string, and
// require "." to list everything.
if (!strlen($path)) {
$path = '.';
}
$future = $repository->getLocalCommandFuture(
'ls-tree --name-only -r -z %s -- %s',
gitsprintf('%s', $commit),
$path);
$lines = id(new LinesOfALargeExecFuture($future))->setDelimiter("\0");
return $this->filterResults($lines, $request);
}
protected function getMercurialResult(ConduitAPIRequest $request) {
$drequest = $this->getDiffusionRequest();
$repository = $drequest->getRepository();
$path = $request->getValue('path');
$commit = $request->getValue('commit');
$entire_manifest = id(new DiffusionLowLevelMercurialPathsQuery())
->setRepository($repository)
->withCommit($commit)
->withPath($path)
->execute();
$match_against = trim($path, '/');
$match_len = strlen($match_against);
$lines = array();
foreach ($entire_manifest as $path) {
if (strlen($path) && !strncmp($path, $match_against, $match_len)) {
$lines[] = $path;
}
}
return $this->filterResults($lines, $request);
}
protected function filterResults($lines, ConduitAPIRequest $request) {
$pattern = $request->getValue('pattern');
$limit = (int)$request->getValue('limit');
$offset = (int)$request->getValue('offset');
if (strlen($pattern)) {
// Add delimiters to the regex pattern.
$pattern = '('.$pattern.')';
}
$results = array();
$count = 0;
foreach ($lines as $line) {
if (strlen($pattern) && !preg_match($pattern, $line)) {
continue;
}
$results[] = $line;
$count++;
if ($limit && ($count >= ($offset + $limit))) {
break;
}
}
return $results;
}
}
| php | Apache-2.0 | 5720a38cfe95b00ca4be5016dd0d2f3195f4fa04 | 2026-01-04T15:03:23.651835Z | false |
phacility/phabricator | https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/diffusion/conduit/DiffusionRepositoryEditConduitAPIMethod.php | src/applications/diffusion/conduit/DiffusionRepositoryEditConduitAPIMethod.php | <?php
final class DiffusionRepositoryEditConduitAPIMethod
extends PhabricatorEditEngineAPIMethod {
public function getAPIMethodName() {
return 'diffusion.repository.edit';
}
public function newEditEngine() {
return new DiffusionRepositoryEditEngine();
}
public function getMethodSummary() {
return pht(
'Apply transactions to create a new repository or edit an existing '.
'one.');
}
}
| php | Apache-2.0 | 5720a38cfe95b00ca4be5016dd0d2f3195f4fa04 | 2026-01-04T15:03:23.651835Z | false |
phacility/phabricator | https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/diffusion/conduit/DiffusionHistoryQueryConduitAPIMethod.php | src/applications/diffusion/conduit/DiffusionHistoryQueryConduitAPIMethod.php | <?php
final class DiffusionHistoryQueryConduitAPIMethod
extends DiffusionQueryConduitAPIMethod {
private $parents = array();
public function getAPIMethodName() {
return 'diffusion.historyquery';
}
public function getMethodDescription() {
return pht(
'Returns history information for a repository at a specific '.
'commit and path.');
}
protected function defineReturnType() {
return 'array';
}
protected function defineCustomParamTypes() {
return array(
'commit' => 'required string',
'against' => 'optional string',
'path' => 'required string',
'offset' => 'required int',
'limit' => 'required int',
'needDirectChanges' => 'optional bool',
'needChildChanges' => 'optional bool',
);
}
protected function getResult(ConduitAPIRequest $request) {
$path_changes = parent::getResult($request);
return array(
'pathChanges' => mpull($path_changes, 'toDictionary'),
'parents' => $this->parents,
);
}
protected function getGitResult(ConduitAPIRequest $request) {
$drequest = $this->getDiffusionRequest();
$repository = $drequest->getRepository();
$commit_hash = $request->getValue('commit');
$against_hash = $request->getValue('against');
$offset = $request->getValue('offset');
$limit = $request->getValue('limit');
$path = $request->getValue('path');
if ($path === null || !strlen($path)) {
$path = null;
}
if ($against_hash !== null && strlen($against_hash)) {
$commit_range = "{$against_hash}..{$commit_hash}";
} else {
$commit_range = $commit_hash;
}
$argv = array();
$argv[] = '--skip';
$argv[] = $offset;
$argv[] = '--max-count';
$argv[] = $limit;
$argv[] = '--format=%H:%P';
$argv[] = gitsprintf('%s', $commit_range);
$argv[] = '--';
if ($path !== null) {
$argv[] = $path;
}
list($stdout) = $repository->execxLocalCommand(
'log %Ls',
$argv);
$lines = explode("\n", trim($stdout));
$lines = array_filter($lines);
$hash_list = array();
$parent_map = array();
foreach ($lines as $line) {
list($hash, $parents) = explode(':', $line);
$hash_list[] = $hash;
$parent_map[$hash] = preg_split('/\s+/', $parents);
}
$this->parents = $parent_map;
if (!$hash_list) {
return array();
}
return DiffusionQuery::loadHistoryForCommitIdentifiers(
$hash_list,
$drequest);
}
protected function getMercurialResult(ConduitAPIRequest $request) {
$drequest = $this->getDiffusionRequest();
$repository = $drequest->getRepository();
$commit_hash = $request->getValue('commit');
$path = $request->getValue('path');
$offset = $request->getValue('offset');
$limit = $request->getValue('limit');
$path = DiffusionPathIDQuery::normalizePath($path);
$path = ltrim($path, '/');
// NOTE: Older versions of Mercurial give different results for these
// commands (see T1268):
//
// $ hg log -- ''
// $ hg log
//
// All versions of Mercurial give different results for these commands
// (merge commits are excluded with the "." version):
//
// $ hg log -- .
// $ hg log
//
// If we don't have a path component in the query, omit it from the command
// entirely to avoid these inconsistencies.
// NOTE: When viewing the history of a file, we don't use "-b", because
// Mercurial stops history at the branchpoint but we're interested in all
// ancestors. When viewing history of a branch, we do use "-b", and thus
// stop history (this is more consistent with the Mercurial worldview of
// branches).
$path_args = array();
if (strlen($path)) {
$path_args[] = $path;
$revset_arg = hgsprintf(
'reverse(ancestors(%s))',
$commit_hash);
} else {
$revset_arg = hgsprintf(
'reverse(ancestors(%s)) and branch(%s)',
$commit_hash,
$drequest->getBranch());
}
$hg_analyzer = PhutilBinaryAnalyzer::getForBinary('hg');
if ($hg_analyzer->isMercurialTemplatePnodeAvailable()) {
$hg_log_template = '{node} {p1.node} {p2.node}\\n';
} else {
$hg_log_template = '{node} {p1node} {p2node}\\n';
}
list($stdout) = $repository->execxLocalCommand(
'log --template %s --limit %d --rev %s -- %Ls',
$hg_log_template,
($offset + $limit), // No '--skip' in Mercurial.
$revset_arg,
$path_args);
$lines = explode("\n", trim($stdout));
$lines = array_slice($lines, $offset);
$hash_list = array();
$parent_map = array();
$last = null;
foreach (array_reverse($lines) as $line) {
$parts = explode(' ', trim($line));
$hash = $parts[0];
$parents = array_slice($parts, 1, 2);
foreach ($parents as $parent) {
if (!preg_match('/^0+\z/', $parent)) {
$parent_map[$hash][] = $parent;
}
}
// This may happen for the zeroth commit in repository, both hashes
// are "000000000...".
if (empty($parent_map[$hash])) {
$parent_map[$hash] = array('...');
}
// The rendering code expects the first commit to be "mainline", like
// Git. Flip the order so it does the right thing.
$parent_map[$hash] = array_reverse($parent_map[$hash]);
$hash_list[] = $hash;
$last = $hash;
}
$hash_list = array_reverse($hash_list);
$this->parents = array_reverse($parent_map, true);
return DiffusionQuery::loadHistoryForCommitIdentifiers(
$hash_list,
$drequest);
}
protected function getSVNResult(ConduitAPIRequest $request) {
$drequest = $this->getDiffusionRequest();
$repository = $drequest->getRepository();
$commit = $request->getValue('commit');
$path = $request->getValue('path');
$offset = $request->getValue('offset');
$limit = $request->getValue('limit');
$need_direct_changes = $request->getValue('needDirectChanges');
$need_child_changes = $request->getValue('needChildChanges');
$conn_r = $repository->establishConnection('r');
$paths = queryfx_all(
$conn_r,
'SELECT id, path FROM %T WHERE pathHash IN (%Ls)',
PhabricatorRepository::TABLE_PATH,
array(md5('/'.trim($path, '/'))));
$paths = ipull($paths, 'id', 'path');
$path_id = idx($paths, '/'.trim($path, '/'));
if (!$path_id) {
return array();
}
$filter_query = qsprintf($conn_r, '');
if ($need_direct_changes) {
if ($need_child_changes) {
$filter_query = qsprintf(
$conn_r,
'AND (isDirect = 1 OR changeType = %s)',
DifferentialChangeType::TYPE_CHILD);
} else {
$filter_query = qsprintf(
$conn_r,
'AND (isDirect = 1)');
}
}
$history_data = queryfx_all(
$conn_r,
'SELECT * FROM %T WHERE repositoryID = %d AND pathID = %d
AND commitSequence <= %d
%Q
ORDER BY commitSequence DESC
LIMIT %d, %d',
PhabricatorRepository::TABLE_PATHCHANGE,
$repository->getID(),
$path_id,
$commit ? $commit : 0x7FFFFFFF,
$filter_query,
$offset,
$limit);
$commits = array();
$commit_data = array();
$commit_ids = ipull($history_data, 'commitID');
if ($commit_ids) {
$commits = id(new PhabricatorRepositoryCommit())->loadAllWhere(
'id IN (%Ld)',
$commit_ids);
if ($commits) {
$commit_data = id(new PhabricatorRepositoryCommitData())->loadAllWhere(
'commitID in (%Ld)',
$commit_ids);
$commit_data = mpull($commit_data, null, 'getCommitID');
}
}
$history = array();
foreach ($history_data as $row) {
$item = new DiffusionPathChange();
$commit = idx($commits, $row['commitID']);
if ($commit) {
$item->setCommit($commit);
$item->setCommitIdentifier($commit->getCommitIdentifier());
$data = idx($commit_data, $commit->getID());
if ($data) {
$item->setCommitData($data);
}
}
$item->setChangeType($row['changeType']);
$item->setFileType($row['fileType']);
$history[] = $item;
}
return $history;
}
}
| php | Apache-2.0 | 5720a38cfe95b00ca4be5016dd0d2f3195f4fa04 | 2026-01-04T15:03:23.651835Z | false |
phacility/phabricator | https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/diffusion/conduit/DiffusionRepositorySearchConduitAPIMethod.php | src/applications/diffusion/conduit/DiffusionRepositorySearchConduitAPIMethod.php | <?php
final class DiffusionRepositorySearchConduitAPIMethod
extends PhabricatorSearchEngineAPIMethod {
public function getAPIMethodName() {
return 'diffusion.repository.search';
}
public function newSearchEngine() {
return new PhabricatorRepositorySearchEngine();
}
public function getMethodSummary() {
return pht('Read information about repositories.');
}
}
| php | Apache-2.0 | 5720a38cfe95b00ca4be5016dd0d2f3195f4fa04 | 2026-01-04T15:03:23.651835Z | false |
phacility/phabricator | https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/diffusion/conduit/DiffusionTagsQueryConduitAPIMethod.php | src/applications/diffusion/conduit/DiffusionTagsQueryConduitAPIMethod.php | <?php
final class DiffusionTagsQueryConduitAPIMethod
extends DiffusionQueryConduitAPIMethod {
public function getAPIMethodName() {
return 'diffusion.tagsquery';
}
public function getMethodDescription() {
return pht('Retrieve information about tags in a repository.');
}
protected function defineReturnType() {
return 'array';
}
protected function defineCustomParamTypes() {
return array(
'names' => 'optional list<string>',
'commit' => 'optional string',
'needMessages' => 'optional bool',
'offset' => 'optional int',
'limit' => 'optional int',
);
}
protected function getGitResult(ConduitAPIRequest $request) {
$drequest = $this->getDiffusionRequest();
$repository = $drequest->getRepository();
$commit = $drequest->getSymbolicCommit();
$commit_filter = null;
if ($commit) {
$commit_filter = $this->loadTagNamesForCommit($commit);
}
$name_filter = $request->getValue('names', null);
$all_tags = $this->loadGitTagList();
$all_tags = mpull($all_tags, null, 'getName');
if ($name_filter !== null) {
$all_tags = array_intersect_key($all_tags, array_fuse($name_filter));
}
if ($commit_filter !== null) {
$all_tags = array_intersect_key($all_tags, $commit_filter);
}
$tags = array_values($all_tags);
$offset = $request->getValue('offset');
$limit = $request->getValue('limit');
if ($offset) {
$tags = array_slice($tags, $offset);
}
if ($limit) {
$tags = array_slice($tags, 0, $limit);
}
if ($request->getValue('needMessages')) {
$this->loadMessagesForTags($all_tags);
}
return mpull($tags, 'toDictionary');
}
private function loadGitTagList() {
$drequest = $this->getDiffusionRequest();
$repository = $drequest->getRepository();
$refs = id(new DiffusionLowLevelGitRefQuery())
->setRepository($repository)
->withRefTypes(
array(
PhabricatorRepositoryRefCursor::TYPE_TAG,
))
->execute();
$tags = array();
foreach ($refs as $ref) {
$fields = $ref->getRawFields();
$tag = id(new DiffusionRepositoryTag())
->setAuthor($fields['author'])
->setEpoch($fields['epoch'])
->setCommitIdentifier($ref->getCommitIdentifier())
->setName($ref->getShortName())
->setDescription($fields['subject'])
->setType('git/'.$fields['objecttype']);
$tags[] = $tag;
}
return $tags;
}
private function loadTagNamesForCommit($commit) {
$drequest = $this->getDiffusionRequest();
$repository = $drequest->getRepository();
list($err, $stdout) = $repository->execLocalCommand(
'tag -l --contains %s',
$commit);
if ($err) {
// Git exits with an error code if the commit is bogus.
return array();
}
$stdout = rtrim($stdout, "\n");
if (!strlen($stdout)) {
return array();
}
$tag_names = explode("\n", $stdout);
$tag_names = array_fill_keys($tag_names, true);
return $tag_names;
}
private function loadMessagesForTags(array $tags) {
assert_instances_of($tags, 'DiffusionRepositoryTag');
$drequest = $this->getDiffusionRequest();
$repository = $drequest->getRepository();
$futures = array();
foreach ($tags as $key => $tag) {
$futures[$key] = $repository->getLocalCommandFuture(
'cat-file tag %s',
$tag->getName());
}
id(new FutureIterator($futures))
->resolveAll();
foreach ($tags as $key => $tag) {
$future = $futures[$key];
list($err, $stdout) = $future->resolve();
$message = null;
if ($err) {
// Not all tags are actually "tag" objects: a "tag" object is only
// created if you provide a message or sign the tag. Tags created with
// `git tag x [commit]` are "lightweight tags" and `git cat-file tag`
// will fail on them. This is fine: they don't have messages.
} else {
$parts = explode("\n\n", $stdout, 2);
if (count($parts) == 2) {
$message = last($parts);
}
}
$tag->attachMessage($message);
}
return $tags;
}
protected function getMercurialResult(ConduitAPIRequest $request) {
// For now, we don't support Mercurial tags via API.
return array();
}
protected function getSVNResult(ConduitAPIRequest $request) {
// Subversion has no meaningful concept of tags.
return array();
}
}
| php | Apache-2.0 | 5720a38cfe95b00ca4be5016dd0d2f3195f4fa04 | 2026-01-04T15:03:23.651835Z | false |
phacility/phabricator | https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/diffusion/conduit/DiffusionCommitSearchConduitAPIMethod.php | src/applications/diffusion/conduit/DiffusionCommitSearchConduitAPIMethod.php | <?php
final class DiffusionCommitSearchConduitAPIMethod
extends PhabricatorSearchEngineAPIMethod {
public function getAPIMethodName() {
return 'diffusion.commit.search';
}
public function newSearchEngine() {
return new PhabricatorCommitSearchEngine();
}
public function getMethodSummary() {
return pht('Read information about commits.');
}
}
| php | Apache-2.0 | 5720a38cfe95b00ca4be5016dd0d2f3195f4fa04 | 2026-01-04T15:03:23.651835Z | false |
phacility/phabricator | https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/diffusion/conduit/DiffusionExistsQueryConduitAPIMethod.php | src/applications/diffusion/conduit/DiffusionExistsQueryConduitAPIMethod.php | <?php
final class DiffusionExistsQueryConduitAPIMethod
extends DiffusionQueryConduitAPIMethod {
public function getAPIMethodName() {
return 'diffusion.existsquery';
}
public function getMethodDescription() {
return pht('Determine if code exists in a version control system.');
}
protected function defineReturnType() {
return 'bool';
}
protected function defineCustomParamTypes() {
return array(
'commit' => 'required string',
);
}
protected function getGitResult(ConduitAPIRequest $request) {
$repository = $this->getDiffusionRequest()->getRepository();
$commit = $request->getValue('commit');
list($err, $merge_base) = $repository->execLocalCommand(
'cat-file -t -- %s',
$commit);
return !$err;
}
protected function getSVNResult(ConduitAPIRequest $request) {
$repository = $this->getDiffusionRequest()->getRepository();
$commit = $request->getValue('commit');
$refs = id(new DiffusionCachedResolveRefsQuery())
->setRepository($repository)
->withRefs(array($commit))
->execute();
return (bool)$refs;
}
protected function getMercurialResult(ConduitAPIRequest $request) {
$repository = $this->getDiffusionRequest()->getRepository();
$commit = $request->getValue('commit');
list($err, $stdout) = $repository->execLocalCommand(
'id --rev %s',
hgsprintf('%s', $commit));
return !$err;
}
}
| php | Apache-2.0 | 5720a38cfe95b00ca4be5016dd0d2f3195f4fa04 | 2026-01-04T15:03:23.651835Z | false |
phacility/phabricator | https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/diffusion/conduit/DiffusionInternalAncestorsConduitAPIMethod.php | src/applications/diffusion/conduit/DiffusionInternalAncestorsConduitAPIMethod.php | <?php
final class DiffusionInternalAncestorsConduitAPIMethod
extends DiffusionQueryConduitAPIMethod {
public function isInternalAPI() {
return true;
}
public function getAPIMethodName() {
return 'diffusion.internal.ancestors';
}
public function getMethodDescription() {
return pht('Internal method for filtering ref ancestors.');
}
protected function defineReturnType() {
return 'list<string>';
}
protected function defineCustomParamTypes() {
return array(
'ref' => 'required string',
'commits' => 'required list<string>',
);
}
protected function getResult(ConduitAPIRequest $request) {
$drequest = $this->getDiffusionRequest();
$repository = $drequest->getRepository();
$commits = $request->getValue('commits');
$ref = $request->getValue('ref');
$graph = new PhabricatorGitGraphStream($repository, $ref);
$keep = array();
foreach ($commits as $identifier) {
try {
$graph->getCommitDate($identifier);
$keep[] = $identifier;
} catch (Exception $ex) {
// Not an ancestor.
}
}
return $keep;
}
}
| php | Apache-2.0 | 5720a38cfe95b00ca4be5016dd0d2f3195f4fa04 | 2026-01-04T15:03:23.651835Z | false |
phacility/phabricator | https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/diffusion/conduit/DiffusionGetRecentCommitsByPathConduitAPIMethod.php | src/applications/diffusion/conduit/DiffusionGetRecentCommitsByPathConduitAPIMethod.php | <?php
final class DiffusionGetRecentCommitsByPathConduitAPIMethod
extends DiffusionConduitAPIMethod {
const DEFAULT_LIMIT = 10;
public function getAPIMethodName() {
return 'diffusion.getrecentcommitsbypath';
}
public function getMethodStatus() {
return self::METHOD_STATUS_DEPRECATED;
}
public function getMethodStatusDescription() {
return pht('Obsoleted by "diffusion.historyquery".');
}
public function getMethodDescription() {
return pht(
'Get commit identifiers for recent commits affecting a given path.');
}
protected function defineParamTypes() {
return array(
'callsign' => 'required string',
'path' => 'required string',
'branch' => 'optional string',
'limit' => 'optional int',
);
}
protected function defineErrorTypes() {
return array(
'ERR_NOT_FOUND' => pht('Repository was not found.'),
);
}
protected function defineReturnType() {
return 'nonempty list<string>';
}
protected function execute(ConduitAPIRequest $request) {
$drequest = DiffusionRequest::newFromDictionary(
array(
'user' => $request->getUser(),
'callsign' => $request->getValue('callsign'),
'path' => $request->getValue('path'),
'branch' => $request->getValue('branch'),
));
if ($drequest === null) {
throw new ConduitException('ERR_NOT_FOUND');
}
$limit = nonempty(
$request->getValue('limit'),
self::DEFAULT_LIMIT);
$history_result = DiffusionQuery::callConduitWithDiffusionRequest(
$request->getUser(),
$drequest,
'diffusion.historyquery',
array(
'commit' => $drequest->getCommit(),
'path' => $drequest->getPath(),
'offset' => 0,
'limit' => $limit,
'needDirectChanges' => true,
'needChildChanges' => true,
));
$history = DiffusionPathChange::newFromConduit(
$history_result['pathChanges']);
$raw_commit_identifiers = mpull($history, 'getCommitIdentifier');
$result = array();
foreach ($raw_commit_identifiers as $id) {
$result[] = 'r'.$request->getValue('callsign').$id;
}
return $result;
}
}
| php | Apache-2.0 | 5720a38cfe95b00ca4be5016dd0d2f3195f4fa04 | 2026-01-04T15:03:23.651835Z | false |
phacility/phabricator | https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/diffusion/conduit/DiffusionInternalCommitSearchConduitAPIMethod.php | src/applications/diffusion/conduit/DiffusionInternalCommitSearchConduitAPIMethod.php | <?php
final class DiffusionInternalCommitSearchConduitAPIMethod
extends PhabricatorSearchEngineAPIMethod {
public function getAPIMethodName() {
return 'internal.commit.search';
}
public function newSearchEngine() {
return new DiffusionInternalCommitSearchEngine();
}
public function getMethodSummary() {
return pht('Read raw information about commits.');
}
protected function newConduitCallProxyClient(ConduitAPIRequest $request) {
$viewer = $request->getViewer();
$constraints = $request->getValue('constraints');
if (is_array($constraints)) {
$repository_phids = idx($constraints, 'repositoryPHIDs');
} else {
$repository_phids = array();
}
$repository_phid = null;
if (is_array($repository_phids)) {
if (phutil_is_natural_list($repository_phids)) {
if (count($repository_phids) === 1) {
$value = head($repository_phids);
if (is_string($value)) {
$repository_phid = $value;
}
}
}
}
if ($repository_phid === null) {
throw new Exception(
pht(
'This internal method must be invoked with a "repositoryPHIDs" '.
'constraint with exactly one value.'));
}
$repository = id(new PhabricatorRepositoryQuery())
->setViewer($viewer)
->withPHIDs(array($repository_phid))
->executeOne();
if (!$repository) {
return array();
}
return $repository->newConduitClientForRequest($request);
}
}
| php | Apache-2.0 | 5720a38cfe95b00ca4be5016dd0d2f3195f4fa04 | 2026-01-04T15:03:23.651835Z | false |
phacility/phabricator | https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/diffusion/conduit/DiffusionInternalGitRawDiffQueryConduitAPIMethod.php | src/applications/diffusion/conduit/DiffusionInternalGitRawDiffQueryConduitAPIMethod.php | <?php
final class DiffusionInternalGitRawDiffQueryConduitAPIMethod
extends DiffusionQueryConduitAPIMethod {
public function isInternalAPI() {
return true;
}
public function getAPIMethodName() {
return 'diffusion.internal.gitrawdiffquery';
}
public function getMethodDescription() {
return pht('Internal method for getting raw diff information.');
}
protected function defineReturnType() {
return 'string';
}
protected function defineCustomParamTypes() {
return array(
'commit' => 'required string',
);
}
protected function getResult(ConduitAPIRequest $request) {
$drequest = $this->getDiffusionRequest();
$repository = $drequest->getRepository();
$commit = $request->getValue('commit');
if (!$repository->isGit()) {
throw new Exception(
pht(
'This API method can only be called on Git repositories.'));
}
// Check if the commit has parents. We're testing to see whether it is the
// first commit in history (in which case we must use "git log") or some
// other commit (in which case we can use "git diff"). We'd rather use
// "git diff" because it has the right behavior for merge commits, but
// it requires the commit to have a parent that we can diff against. The
// first commit doesn't, so "commit^" is not a valid ref.
list($parents) = $repository->execxLocalCommand(
'log -n1 %s %s --',
'--format=%P',
gitsprintf('%s', $commit));
$use_log = !strlen(trim($parents));
// First, get a fast raw diff without "--find-copies-harder". This flag
// produces better results for moves and copies, but is explosively slow
// for large changes to large repositories. See T10423.
$raw = $this->getRawDiff($repository, $commit, $use_log, false);
// If we got a normal-sized diff (no more than 100 modified files), we'll
// try using "--find-copies-harder" to improve the output. This improved
// output is mostly useful for small changes anyway.
$try_harder = (substr_count($raw, "\n") <= 100);
if ($try_harder) {
try {
$raw = $this->getRawDiff($repository, $commit, $use_log, true);
} catch (Exception $ex) {
// Just ignore any exception we hit, we'll use the fast output
// instead.
}
}
return $raw;
}
private function getRawDiff(
PhabricatorRepository $repository,
$commit,
$use_log,
$try_harder) {
$flags = array(
'-n1',
'-M',
'-C',
'-B',
'--raw',
'-t',
'--abbrev=40',
);
if ($try_harder) {
$flags[] = '--find-copies-harder';
}
if ($use_log) {
// This is the first commit so we need to use "log". We know it's not a
// merge commit because it couldn't be merging anything, so this is safe.
// NOTE: "--pretty=format: " is to disable diff output, we only want the
// part we get from "--raw".
$future = $repository->getLocalCommandFuture(
'log %Ls --pretty=format: %s --',
$flags,
gitsprintf('%s', $commit));
} else {
// Otherwise, we can use "diff", which will give us output for merges.
// We diff against the first parent, as this is generally the expectation
// and results in sensible behavior.
$future = $repository->getLocalCommandFuture(
'diff %Ls %s %s --',
$flags,
gitsprintf('%s^1', $commit),
gitsprintf('%s', $commit));
}
// Don't spend more than 30 seconds generating the slower output.
if ($try_harder) {
$future->setTimeout(30);
}
list($raw) = $future->resolvex();
return $raw;
}
}
| php | Apache-2.0 | 5720a38cfe95b00ca4be5016dd0d2f3195f4fa04 | 2026-01-04T15:03:23.651835Z | false |
phacility/phabricator | https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/diffusion/conduit/DiffusionCommitParentsQueryConduitAPIMethod.php | src/applications/diffusion/conduit/DiffusionCommitParentsQueryConduitAPIMethod.php | <?php
final class DiffusionCommitParentsQueryConduitAPIMethod
extends DiffusionQueryConduitAPIMethod {
public function getAPIMethodName() {
return 'diffusion.commitparentsquery';
}
public function getMethodDescription() {
return pht(
"Get the commit identifiers for a commit's parent or parents.");
}
protected function defineReturnType() {
return 'list<string>';
}
protected function defineCustomParamTypes() {
return array(
'commit' => 'required string',
);
}
protected function getResult(ConduitAPIRequest $request) {
$repository = $this->getRepository($request);
return id(new DiffusionLowLevelParentsQuery())
->setRepository($repository)
->withIdentifier($request->getValue('commit'))
->execute();
}
}
| php | Apache-2.0 | 5720a38cfe95b00ca4be5016dd0d2f3195f4fa04 | 2026-01-04T15:03:23.651835Z | false |
phacility/phabricator | https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/diffusion/conduit/DiffusionFindSymbolsConduitAPIMethod.php | src/applications/diffusion/conduit/DiffusionFindSymbolsConduitAPIMethod.php | <?php
final class DiffusionFindSymbolsConduitAPIMethod
extends DiffusionConduitAPIMethod {
public function getAPIMethodName() {
return 'diffusion.findsymbols';
}
public function getMethodDescription() {
return pht('Retrieve Diffusion symbol information.');
}
protected function defineParamTypes() {
return array(
'name' => 'optional string',
'namePrefix' => 'optional string',
'context' => 'optional string',
'language' => 'optional string',
'type' => 'optional string',
'repositoryPHID' => 'optional string',
);
}
protected function defineReturnType() {
return 'nonempty list<dict>';
}
protected function execute(ConduitAPIRequest $request) {
$name = $request->getValue('name');
$name_prefix = $request->getValue('namePrefix');
$context = $request->getValue('context');
$language = $request->getValue('language');
$type = $request->getValue('type');
$repository = $request->getValue('repositoryPHID');
$query = id(new DiffusionSymbolQuery())
->setViewer($request->getUser());
if ($name !== null) {
$query->setName($name);
}
if ($name_prefix !== null) {
$query->setNamePrefix($name_prefix);
}
if ($context !== null) {
$query->setContext($context);
}
if ($language !== null) {
$query->setLanguage($language);
}
if ($type !== null) {
$query->setType($type);
}
if ($repository !== null) {
$query->withRepositoryPHIDs(array($repository));
}
$query->needPaths(true);
$query->needRepositories(true);
$results = $query->execute();
$response = array();
foreach ($results as $result) {
$uri = $result->getURI();
if ($uri) {
$uri = PhabricatorEnv::getProductionURI($uri);
}
$response[] = array(
'name' => $result->getSymbolName(),
'context' => $result->getSymbolContext(),
'type' => $result->getSymbolType(),
'language' => $result->getSymbolLanguage(),
'path' => $result->getPath(),
'line' => $result->getLineNumber(),
'uri' => $uri,
'repositoryPHID' => $result->getRepository()->getPHID(),
);
}
return $response;
}
}
| php | Apache-2.0 | 5720a38cfe95b00ca4be5016dd0d2f3195f4fa04 | 2026-01-04T15:03:23.651835Z | false |
phacility/phabricator | https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/diffusion/conduit/DiffusionRefsQueryConduitAPIMethod.php | src/applications/diffusion/conduit/DiffusionRefsQueryConduitAPIMethod.php | <?php
final class DiffusionRefsQueryConduitAPIMethod
extends DiffusionQueryConduitAPIMethod {
public function getAPIMethodName() {
return 'diffusion.refsquery';
}
public function getMethodDescription() {
return pht(
'Query a git repository for ref information at a specific commit.');
}
protected function defineReturnType() {
return 'array';
}
protected function defineCustomParamTypes() {
return array(
'commit' => 'required string',
);
}
protected function getGitResult(ConduitAPIRequest $request) {
$drequest = $this->getDiffusionRequest();
$repository = $drequest->getRepository();
$commit = $request->getValue('commit');
list($stdout) = $repository->execxLocalCommand(
'log -n 1 %s %s --',
'--format=%d',
gitsprintf('%s', $commit));
// %d, gives a weird output format
// similar to (remote/one, remote/two, remote/three)
$refs = trim($stdout, "() \n");
if (!$refs) {
return array();
}
$refs = explode(',', $refs);
$refs = array_map('trim', $refs);
$ref_links = array();
foreach ($refs as $ref) {
$ref_links[] = array(
'ref' => $ref,
'href' => $drequest->generateURI(
array(
'action' => 'browse',
'branch' => $ref,
)),
);
}
return $ref_links;
}
}
| php | Apache-2.0 | 5720a38cfe95b00ca4be5016dd0d2f3195f4fa04 | 2026-01-04T15:03:23.651835Z | false |
phacility/phabricator | https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/diffusion/conduit/DiffusionQueryConduitAPIMethod.php | src/applications/diffusion/conduit/DiffusionQueryConduitAPIMethod.php | <?php
abstract class DiffusionQueryConduitAPIMethod
extends DiffusionConduitAPIMethod {
public function shouldAllowPublic() {
return true;
}
private $diffusionRequest;
private $repository;
protected function setDiffusionRequest(DiffusionRequest $request) {
$this->diffusionRequest = $request;
return $this;
}
protected function getDiffusionRequest() {
return $this->diffusionRequest;
}
protected function getRepository(ConduitAPIRequest $request) {
return $this->getDiffusionRequest()->getRepository();
}
final protected function defineErrorTypes() {
return $this->defineCustomErrorTypes() +
array(
'ERR-UNKNOWN-REPOSITORY' =>
pht('There is no matching repository.'),
'ERR-UNKNOWN-VCS-TYPE' =>
pht('Unknown repository VCS type.'),
'ERR-UNSUPPORTED-VCS' =>
pht('VCS is not supported for this method.'),
);
}
/**
* Subclasses should override this to specify custom error types.
*/
protected function defineCustomErrorTypes() {
return array();
}
final protected function defineParamTypes() {
return $this->defineCustomParamTypes() +
array(
'callsign' => 'optional string (deprecated)',
'repository' => 'optional string',
'branch' => 'optional string',
);
}
/**
* Subclasses should override this to specify custom param types.
*/
protected function defineCustomParamTypes() {
return array();
}
/**
* Subclasses should override these methods with the proper result for the
* pertinent version control system, e.g. getGitResult for Git.
*
* If the result is not supported for that VCS, do not implement it. e.g.
* Subversion (SVN) does not support branches.
*/
protected function getGitResult(ConduitAPIRequest $request) {
throw new ConduitException('ERR-UNSUPPORTED-VCS');
}
protected function getSVNResult(ConduitAPIRequest $request) {
throw new ConduitException('ERR-UNSUPPORTED-VCS');
}
protected function getMercurialResult(ConduitAPIRequest $request) {
throw new ConduitException('ERR-UNSUPPORTED-VCS');
}
/**
* This method is final because most queries will need to construct a
* @{class:DiffusionRequest} and use it. Consolidating this codepath and
* enforcing @{method:getDiffusionRequest} works when we need it is good.
*
* @{method:getResult} should be overridden by subclasses as necessary, e.g.
* there is a common operation across all version control systems that
* should occur after @{method:getResult}, like formatting a timestamp.
*/
final protected function execute(ConduitAPIRequest $request) {
$drequest = $this->getDiffusionRequest();
// We pass this flag on to prevent proxying of any other Conduit calls
// which we need to make in order to respond to this one. Although we
// could safely proxy them, we take a big performance hit in the common
// case, and doing more proxying wouldn't exercise any additional code so
// we wouldn't gain a testability/predictability benefit.
$is_cluster_request = $request->getIsClusterRequest();
$drequest->setIsClusterRequest($is_cluster_request);
$viewer = $request->getViewer();
$repository = $drequest->getRepository();
// TODO: Allow web UI queries opt out of this if they don't care about
// fetching the most up-to-date data? Synchronization can be slow, and a
// lot of web reads are probably fine if they're a few seconds out of
// date.
id(new DiffusionRepositoryClusterEngine())
->setViewer($viewer)
->setRepository($repository)
->synchronizeWorkingCopyBeforeRead();
return $this->getResult($request);
}
protected function newConduitCallProxyClient(ConduitAPIRequest $request) {
$viewer = $request->getViewer();
$identifier = $request->getValue('repository');
if ($identifier === null) {
$identifier = $request->getValue('callsign');
}
$drequest = DiffusionRequest::newFromDictionary(
array(
'user' => $viewer,
'repository' => $identifier,
'branch' => $request->getValue('branch'),
'path' => $request->getValue('path'),
'commit' => $request->getValue('commit'),
));
if (!$drequest) {
throw new Exception(
pht(
'Repository "%s" is not a valid repository.',
$identifier));
}
$repository = $drequest->getRepository();
$client = $repository->newConduitClientForRequest($request);
if ($client) {
return $client;
}
$this->setDiffusionRequest($drequest);
return null;
}
protected function getResult(ConduitAPIRequest $request) {
$repository = $this->getRepository($request);
$result = null;
switch ($repository->getVersionControlSystem()) {
case PhabricatorRepositoryType::REPOSITORY_TYPE_GIT:
$result = $this->getGitResult($request);
break;
case PhabricatorRepositoryType::REPOSITORY_TYPE_MERCURIAL:
$result = $this->getMercurialResult($request);
break;
case PhabricatorRepositoryType::REPOSITORY_TYPE_SVN:
$result = $this->getSVNResult($request);
break;
default:
throw new ConduitException('ERR-UNKNOWN-VCS-TYPE');
break;
}
return $result;
}
}
| php | Apache-2.0 | 5720a38cfe95b00ca4be5016dd0d2f3195f4fa04 | 2026-01-04T15:03:23.651835Z | false |
phacility/phabricator | https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/diffusion/conduit/DiffusionResolveRefsConduitAPIMethod.php | src/applications/diffusion/conduit/DiffusionResolveRefsConduitAPIMethod.php | <?php
final class DiffusionResolveRefsConduitAPIMethod
extends DiffusionQueryConduitAPIMethod {
public function getAPIMethodName() {
return 'diffusion.resolverefs';
}
public function getMethodDescription() {
return pht('Resolve references into stable, canonical identifiers.');
}
protected function defineReturnType() {
return 'dict<string, list<dict<string, wild>>>';
}
protected function defineCustomParamTypes() {
return array(
'refs' => 'required list<string>',
'types' => 'optional list<string>',
);
}
protected function getResult(ConduitAPIRequest $request) {
$refs = $request->getValue('refs');
$types = $request->getValue('types');
$query = id(new DiffusionLowLevelResolveRefsQuery())
->setRepository($this->getDiffusionRequest()->getRepository())
->withRefs($refs);
if ($types) {
$query->withTypes($types);
}
return $query->execute();
}
}
| php | Apache-2.0 | 5720a38cfe95b00ca4be5016dd0d2f3195f4fa04 | 2026-01-04T15:03:23.651835Z | false |
phacility/phabricator | https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/diffusion/conduit/DiffusionFileContentQueryConduitAPIMethod.php | src/applications/diffusion/conduit/DiffusionFileContentQueryConduitAPIMethod.php | <?php
final class DiffusionFileContentQueryConduitAPIMethod
extends DiffusionQueryConduitAPIMethod {
public function getAPIMethodName() {
return 'diffusion.filecontentquery';
}
public function getMethodDescription() {
return pht('Retrieve file content from a repository.');
}
protected function defineReturnType() {
return 'array';
}
protected function defineCustomParamTypes() {
return array(
'path' => 'required string',
'commit' => 'required string',
) + DiffusionFileFutureQuery::getConduitParameters();
}
protected function getResult(ConduitAPIRequest $request) {
$drequest = $this->getDiffusionRequest();
return DiffusionFileContentQuery::newFromDiffusionRequest($drequest)
->respondToConduitRequest($request);
}
}
| php | Apache-2.0 | 5720a38cfe95b00ca4be5016dd0d2f3195f4fa04 | 2026-01-04T15:03:23.651835Z | false |
phacility/phabricator | https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/diffusion/conduit/DiffusionQueryCommitsConduitAPIMethod.php | src/applications/diffusion/conduit/DiffusionQueryCommitsConduitAPIMethod.php | <?php
final class DiffusionQueryCommitsConduitAPIMethod
extends DiffusionConduitAPIMethod {
public function getAPIMethodName() {
return 'diffusion.querycommits';
}
public function getMethodDescription() {
return pht('Retrieve information about commits.');
}
public function getMethodStatus() {
return self::METHOD_STATUS_FROZEN;
}
public function getMethodStatusDescription() {
return pht(
'This method is frozen and will eventually be deprecated. New code '.
'should use "diffusion.commit.search" instead.');
}
protected function defineReturnType() {
return 'map<string, dict>';
}
protected function defineParamTypes() {
return array(
'ids' => 'optional list<int>',
'phids' => 'optional list<phid>',
'names' => 'optional list<string>',
'repositoryPHID' => 'optional phid',
'needMessages' => 'optional bool',
'bypassCache' => 'optional bool',
) + $this->getPagerParamTypes();
}
protected function execute(ConduitAPIRequest $request) {
$need_messages = $request->getValue('needMessages');
$viewer = $request->getUser();
$query = id(new DiffusionCommitQuery())
->setViewer($viewer)
->needCommitData(true);
$repository_phid = $request->getValue('repositoryPHID');
if ($repository_phid) {
$repository = id(new PhabricatorRepositoryQuery())
->setViewer($viewer)
->withPHIDs(array($repository_phid))
->executeOne();
if ($repository) {
$query->withRepository($repository);
}
}
$names = $request->getValue('names');
if ($names) {
$query->withIdentifiers($names);
}
$ids = $request->getValue('ids');
if ($ids) {
$query->withIDs($ids);
}
$phids = $request->getValue('phids');
if ($phids) {
$query->withPHIDs($phids);
}
$pager = $this->newPager($request);
$commits = $query->executeWithCursorPager($pager);
$map = $query->getIdentifierMap();
$map = mpull($map, 'getPHID');
$data = array();
foreach ($commits as $commit) {
$commit_data = $commit->getCommitData();
$uri = $commit->getURI();
$uri = PhabricatorEnv::getProductionURI($uri);
$dict = array(
'id' => $commit->getID(),
'phid' => $commit->getPHID(),
'repositoryPHID' => $commit->getRepository()->getPHID(),
'identifier' => $commit->getCommitIdentifier(),
'epoch' => $commit->getEpoch(),
'authorEpoch' => $commit_data->getAuthorEpoch(),
'uri' => $uri,
'isImporting' => !$commit->isImported(),
'summary' => $commit->getSummary(),
'authorPHID' => $commit->getAuthorPHID(),
'committerPHID' => $commit_data->getCommitDetail('committerPHID'),
'author' => $commit_data->getAuthorString(),
'authorName' => $commit_data->getAuthorDisplayName(),
'authorEmail' => $commit_data->getAuthorEmail(),
'committer' => $commit_data->getCommitterString(),
'committerName' => $commit_data->getCommitterDisplayName(),
'committerEmail' => $commit_data->getCommitterEmail(),
'hashes' => array(),
);
if ($need_messages) {
$dict['message'] = $commit_data->getCommitMessage();
}
$data[$commit->getPHID()] = $dict;
}
$result = array(
'data' => $data,
'identifierMap' => nonempty($map, (object)array()),
);
return $this->addPagerResults($result, $pager);
}
}
| php | Apache-2.0 | 5720a38cfe95b00ca4be5016dd0d2f3195f4fa04 | 2026-01-04T15:03:23.651835Z | false |
phacility/phabricator | https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/diffusion/conduit/DiffusionLookSoonConduitAPIMethod.php | src/applications/diffusion/conduit/DiffusionLookSoonConduitAPIMethod.php | <?php
final class DiffusionLookSoonConduitAPIMethod
extends DiffusionConduitAPIMethod {
public function getAPIMethodName() {
return 'diffusion.looksoon';
}
public function getMethodStatus() {
return self::METHOD_STATUS_UNSTABLE;
}
public function getMethodDescription() {
return pht(
'Advises this server to look for new commits in a repository as soon '.
'as possible. This advice is most useful if you have just pushed new '.
'commits to that repository.');
}
protected function defineReturnType() {
return 'void';
}
protected function defineParamTypes() {
return array(
'callsigns' => 'optional list<string> (deprecated)',
'repositories' => 'optional list<string>',
'urgency' => 'optional string',
);
}
protected function execute(ConduitAPIRequest $request) {
// NOTE: The "urgency" parameter does nothing, it is just a hilarious joke
// which exemplifies the boundless clever wit of this project.
$identifiers = $request->getValue('repositories');
if (!$identifiers) {
$identifiers = $request->getValue('callsigns');
}
if (!$identifiers) {
return null;
}
$repositories = id(new PhabricatorRepositoryQuery())
->setViewer($request->getUser())
->withIdentifiers($identifiers)
->execute();
foreach ($repositories as $repository) {
$repository->writeStatusMessage(
PhabricatorRepositoryStatusMessage::TYPE_NEEDS_UPDATE,
PhabricatorRepositoryStatusMessage::CODE_OKAY);
}
return null;
}
}
| php | Apache-2.0 | 5720a38cfe95b00ca4be5016dd0d2f3195f4fa04 | 2026-01-04T15:03:23.651835Z | false |
phacility/phabricator | https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/diffusion/conduit/DiffusionConduitAPIMethod.php | src/applications/diffusion/conduit/DiffusionConduitAPIMethod.php | <?php
abstract class DiffusionConduitAPIMethod extends ConduitAPIMethod {
final public function getApplication() {
return PhabricatorApplication::getByClass(
'PhabricatorDiffusionApplication');
}
}
| php | Apache-2.0 | 5720a38cfe95b00ca4be5016dd0d2f3195f4fa04 | 2026-01-04T15:03:23.651835Z | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.