Changeset View
Changeset View
Standalone View
Standalone View
src/applications/repository/storage/PhabricatorRepository.php
Show First 20 Lines • Show All 571 Lines • ▼ Show 20 Lines | /* -( Command Infrastructure )--------------------------------------------- */ | ||||
} | } | ||||
private function isBranchInFilter($branch, $filter_key) { | private function isBranchInFilter($branch, $filter_key) { | ||||
$vcs = $this->getVersionControlSystem(); | $vcs = $this->getVersionControlSystem(); | ||||
$is_git = ($vcs == PhabricatorRepositoryType::REPOSITORY_TYPE_GIT); | $is_git = ($vcs == PhabricatorRepositoryType::REPOSITORY_TYPE_GIT); | ||||
$use_filter = ($is_git); | $use_filter = ($is_git); | ||||
if (!$use_filter) { | |||||
// If this VCS doesn't use filters, pass everything through. | |||||
return true; | |||||
} | |||||
if ($use_filter) { | |||||
$filter = $this->getDetail($filter_key, array()); | $filter = $this->getDetail($filter_key, array()); | ||||
if ($filter && empty($filter[$branch])) { | |||||
return false; | // If there's no filter set, let everything through. | ||||
if (!$filter) { | |||||
return true; | |||||
} | |||||
// If this branch isn't literally named `regexp(...)`, and it's in the | |||||
// filter list, let it through. | |||||
if (isset($filter[$branch])) { | |||||
if (self::extractBranchRegexp($branch) === null) { | |||||
return true; | |||||
} | } | ||||
} | } | ||||
// By default, all branches pass. | // If the branch matches a regexp, let it through. | ||||
foreach ($filter as $pattern => $ignored) { | |||||
$regexp = self::extractBranchRegexp($pattern); | |||||
if ($regexp !== null) { | |||||
if (preg_match($regexp, $branch)) { | |||||
return true; | return true; | ||||
} | } | ||||
} | |||||
} | |||||
// Nothing matched, so filter this branch out. | |||||
return false; | |||||
} | |||||
public static function extractBranchRegexp($pattern) { | |||||
$matches = null; | |||||
if (preg_match('/^regexp\\((.*)\\)\z/', $pattern, $matches)) { | |||||
return $matches[1]; | |||||
} | |||||
return null; | |||||
} | |||||
public function shouldTrackBranch($branch) { | public function shouldTrackBranch($branch) { | ||||
return $this->isBranchInFilter($branch, 'branch-filter'); | return $this->isBranchInFilter($branch, 'branch-filter'); | ||||
} | } | ||||
public function formatCommitName($commit_identifier) { | public function formatCommitName($commit_identifier) { | ||||
$vcs = $this->getVersionControlSystem(); | $vcs = $this->getVersionControlSystem(); | ||||
▲ Show 20 Lines • Show All 936 Lines • Show Last 20 Lines |