Changeset View
Changeset View
Standalone View
Standalone View
src/browse/loader/ArcanistBrowseCommitHardpointLoader.php
Show All 27 Lines | public function loadHardpoints(array $refs, $hardpoint) { | ||||
$repository_ref = $query->getRepositoryRef(); | $repository_ref = $query->getRepositoryRef(); | ||||
if (!$repository_ref) { | if (!$repository_ref) { | ||||
return array(); | return array(); | ||||
} | } | ||||
$repository_phid = $repository_ref->getPHID(); | $repository_phid = $repository_ref->getPHID(); | ||||
$commit_map = array(); | $commit_map = array(); | ||||
foreach ($refs as $key => $ref) { | foreach ($refs as $key => $ref) { | ||||
$is_commit = $ref->hasType( | |||||
ArcanistBrowseCommitURIHardpointLoader::BROWSETYPE); | |||||
$token = $ref->getToken(); | $token = $ref->getToken(); | ||||
if ($token === '.') { | if ($token === '.') { | ||||
// Git resolves "." like HEAD, but we want to treat it as "browse the | // Git resolves "." like HEAD, but we want to treat it as "browse the | ||||
// current directory" instead in all cases. | // current directory" instead in all cases. | ||||
continue; | continue; | ||||
} | } | ||||
// Always resolve the empty token; top-level loaders filter out | |||||
// irrelevant tokens before this stage. | |||||
if ($token === null) { | if ($token === null) { | ||||
if ($is_commit) { | |||||
$token = $api->getHeadCommit(); | $token = $api->getHeadCommit(); | ||||
} else { | |||||
continue; | |||||
} | |||||
} | } | ||||
// TODO: We should pull a full commit ref out of the API as soon as it | |||||
// is able to provide them. In particular, we currently miss Git tree | |||||
// hashes which reduces the accuracy of lookups. | |||||
try { | try { | ||||
$commit = $api->getCanonicalRevisionName($token); | $commit = $api->getCanonicalRevisionName($token); | ||||
if ($commit) { | if ($commit) { | ||||
$commit_map[$commit][] = $key; | $commit_map[$commit][] = $key; | ||||
} | } | ||||
} catch (Exception $ex) { | } catch (Exception $ex) { | ||||
// Ignore anything we can't resolve. | // Ignore anything we can't resolve. | ||||
} | } | ||||
Show All 19 Lines |