Differential D20465 Diff 48839 src/applications/repository/engine/PhabricatorRepositoryDiscoveryEngine.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/repository/engine/PhabricatorRepositoryDiscoveryEngine.php
Show First 20 Lines • Show All 121 Lines • ▼ Show 20 Lines | |||||
/* -( Discovering Git Repositories )--------------------------------------- */ | /* -( Discovering Git Repositories )--------------------------------------- */ | ||||
/** | /** | ||||
* @task git | * @task git | ||||
*/ | */ | ||||
private function discoverGitCommits() { | private function discoverGitCommits() { | ||||
$repository = $this->getRepository(); | $repository = $this->getRepository(); | ||||
$publisher = $repository->newPublisher(); | |||||
$heads = id(new DiffusionLowLevelGitRefQuery()) | $heads = id(new DiffusionLowLevelGitRefQuery()) | ||||
->setRepository($repository) | ->setRepository($repository) | ||||
->execute(); | ->execute(); | ||||
if (!$heads) { | if (!$heads) { | ||||
// This repository has no heads at all, so we don't need to do | // This repository has no heads at all, so we don't need to do | ||||
// anything. Generally, this means the repository is empty. | // anything. Generally, this means the repository is empty. | ||||
▲ Show 20 Lines • Show All 42 Lines • ▼ Show 20 Lines | foreach ($heads as $ref) { | ||||
continue; | continue; | ||||
} | } | ||||
$this->log(pht('Looking for new commits.')); | $this->log(pht('Looking for new commits.')); | ||||
$head_refs = $this->discoverStreamAncestry( | $head_refs = $this->discoverStreamAncestry( | ||||
new PhabricatorGitGraphStream($repository, $commit), | new PhabricatorGitGraphStream($repository, $commit), | ||||
$commit, | $commit, | ||||
$repository->shouldAutocloseRef($ref)); | $publisher->shouldPublishRef($ref)); | ||||
$this->didDiscoverRefs($head_refs); | $this->didDiscoverRefs($head_refs); | ||||
$refs[] = $head_refs; | $refs[] = $head_refs; | ||||
} | } | ||||
return array_mergev($refs); | return array_mergev($refs); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 312 Lines • ▼ Show 20 Lines | /* -( Internals )---------------------------------------------------------- */ | ||||
* | * | ||||
* @task internal | * @task internal | ||||
* | * | ||||
* @param list<DiffusionRepositoryRef> List of refs. | * @param list<DiffusionRepositoryRef> List of refs. | ||||
* @return list<DiffusionRepositoryRef> Sorted list of refs. | * @return list<DiffusionRepositoryRef> Sorted list of refs. | ||||
*/ | */ | ||||
private function sortRefs(array $refs) { | private function sortRefs(array $refs) { | ||||
$repository = $this->getRepository(); | $repository = $this->getRepository(); | ||||
$publisher = $repository->newPublisher(); | |||||
$head_refs = array(); | $head_refs = array(); | ||||
$tail_refs = array(); | $tail_refs = array(); | ||||
foreach ($refs as $ref) { | foreach ($refs as $ref) { | ||||
if ($repository->shouldAutocloseRef($ref)) { | if ($publisher->shouldPublishRef($ref)) { | ||||
$head_refs[] = $ref; | $head_refs[] = $ref; | ||||
} else { | } else { | ||||
$tail_refs[] = $ref; | $tail_refs[] = $ref; | ||||
} | } | ||||
} | } | ||||
return array_merge($head_refs, $tail_refs); | return array_merge($head_refs, $tail_refs); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 406 Lines • Show Last 20 Lines |