Changeset View
Changeset View
Standalone View
Standalone View
src/applications/owners/query/PhabricatorOwnersPackageQuery.php
Show First 20 Lines • Show All 347 Lines • ▼ Show 20 Lines | public function getControllingPackagesForPath($repository_phid, $path) { | ||||
if ($this->controlResults === null) { | if ($this->controlResults === null) { | ||||
throw new PhutilInvalidStateException('execute'); | throw new PhutilInvalidStateException('execute'); | ||||
} | } | ||||
$packages = $this->controlResults; | $packages = $this->controlResults; | ||||
$weak_dominion = PhabricatorOwnersPackage::DOMINION_WEAK; | $weak_dominion = PhabricatorOwnersPackage::DOMINION_WEAK; | ||||
$path_fragments = PhabricatorOwnersPackage::splitPath($path); | |||||
$fragment_count = count($path_fragments); | |||||
$matches = array(); | $matches = array(); | ||||
foreach ($packages as $package_id => $package) { | foreach ($packages as $package_id => $package) { | ||||
$best_match = null; | $best_match = null; | ||||
$include = false; | $include = false; | ||||
// If this package is archived, it's no longer a controlling package | // If this package is archived, it's no longer a controlling package | ||||
// for the given path. In particular, it can not force active packages | // for the given path. In particular, it can not force active packages | ||||
// with weak dominion to give up control. | // with weak dominion to give up control. | ||||
if ($package->isArchived()) { | if ($package->isArchived()) { | ||||
continue; | continue; | ||||
} | } | ||||
foreach ($package->getPaths() as $package_path) { | $repository_paths = $package->getPathsForRepository($repository_phid); | ||||
if ($package_path->getRepositoryPHID() != $repository_phid) { | foreach ($repository_paths as $package_path) { | ||||
// If this path is for some other repository, skip it. | $strength = $package_path->getPathMatchStrength( | ||||
continue; | $path_fragments, | ||||
} | $fragment_count); | ||||
$strength = $package_path->getPathMatchStrength($path); | |||||
if ($strength > $best_match) { | if ($strength > $best_match) { | ||||
$best_match = $strength; | $best_match = $strength; | ||||
$include = !$package_path->getExcluded(); | $include = !$package_path->getExcluded(); | ||||
} | } | ||||
} | } | ||||
if ($best_match && $include) { | if ($best_match && $include) { | ||||
$matches[$package_id] = array( | $matches[$package_id] = array( | ||||
Show All 26 Lines |