Changeset View
Changeset View
Standalone View
Standalone View
src/repository/marker/ArcanistRepositoryMarkerQuery.php
| <?php | <?php | ||||
| abstract class ArcanistRepositoryMarkerQuery | abstract class ArcanistRepositoryMarkerQuery | ||||
| extends ArcanistRepositoryQuery { | extends ArcanistRepositoryQuery { | ||||
| private $isActive; | private $isActive; | ||||
| private $markerTypes; | private $markerTypes; | ||||
| private $names; | private $names; | ||||
| private $commitHashes; | private $commitHashes; | ||||
| private $ancestorCommitHashes; | private $ancestorCommitHashes; | ||||
| private $remotes; | private $remotes; | ||||
| private $isRemoteCache = false; | |||||
| final public function withMarkerTypes(array $types) { | final public function withMarkerTypes(array $types) { | ||||
| $this->markerTypes = array_fuse($types); | $this->markerTypes = array_fuse($types); | ||||
| return $this; | return $this; | ||||
| } | } | ||||
| final public function withNames(array $names) { | final public function withNames(array $names) { | ||||
| $this->names = array_fuse($names); | $this->names = array_fuse($names); | ||||
| return $this; | return $this; | ||||
| } | } | ||||
| final public function withRemotes(array $remotes) { | final public function withRemotes(array $remotes) { | ||||
| assert_instances_of($remotes, 'ArcanistRemoteRef'); | assert_instances_of($remotes, 'ArcanistRemoteRef'); | ||||
| $this->remotes = $remotes; | $this->remotes = $remotes; | ||||
| return $this; | return $this; | ||||
| } | } | ||||
| final public function withIsRemoteCache($is_cache) { | |||||
| $this->isRemoteCache = $is_cache; | |||||
| return $this; | |||||
| } | |||||
| final public function withIsActive($active) { | final public function withIsActive($active) { | ||||
| $this->isActive = $active; | $this->isActive = $active; | ||||
| return $this; | return $this; | ||||
| } | } | ||||
| final public function execute() { | final public function execute() { | ||||
| $remotes = $this->remotes; | $remotes = $this->remotes; | ||||
| if ($remotes !== null) { | if ($remotes !== null) { | ||||
| ▲ Show 20 Lines • Show All 46 Lines • ▼ Show 20 Lines | final public function execute() { | ||||
| if ($this->isActive !== null) { | if ($this->isActive !== null) { | ||||
| foreach ($markers as $key => $marker) { | foreach ($markers as $key => $marker) { | ||||
| if ($marker->getIsActive() !== $this->isActive) { | if ($marker->getIsActive() !== $this->isActive) { | ||||
| unset($markers[$key]); | unset($markers[$key]); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| if ($this->isRemoteCache !== null) { | |||||
| $want_cache = $this->isRemoteCache; | |||||
| foreach ($markers as $key => $marker) { | |||||
| $is_cache = ($marker->getRemoteName() !== null); | |||||
| if ($is_cache !== $want_cache) { | |||||
| unset($markers[$key]); | |||||
| } | |||||
| } | |||||
| } | |||||
| return $this->sortMarkers($markers); | return $this->sortMarkers($markers); | ||||
| } | } | ||||
| private function sortMarkers(array $markers) { | private function sortMarkers(array $markers) { | ||||
| // Sort the list in natural order. If we apply a stable sort later, | // Sort the list in natural order. If we apply a stable sort later, | ||||
| // markers will sort in "feature1", "feature2", etc., order if they | // markers will sort in "feature1", "feature2", etc., order if they | ||||
| // don't otherwise have a unique position. | // don't otherwise have a unique position. | ||||
| Show All 22 Lines | |||||