mirror of
https://we.phorge.it/source/phorge.git
synced 2025-02-24 04:29:04 +01:00
Summary: Ref T4245. Standardize how context is read, minor updates / modernizations / consistency tweaks. Test Plan: - Viewed a change. - Viewed brnaches. - Edited a commit. - Viewed tags. - Viewed history. - Added, edited and deleted a mirror. - Viewed push events. - Viewed a particular event. - Viewed ref disambiguation. - Viewed repository list. - Ran automation test. Reviewers: chad Reviewed By: chad Maniphest Tasks: T4245 Differential Revision: https://secure.phabricator.com/D14944
150 lines
3.8 KiB
PHP
150 lines
3.8 KiB
PHP
<?php
|
|
|
|
final class DiffusionRefTableController extends DiffusionController {
|
|
|
|
public function shouldAllowPublic() {
|
|
return true;
|
|
}
|
|
|
|
public function handleRequest(AphrontRequest $request) {
|
|
$response = $this->loadDiffusionContext();
|
|
if ($response) {
|
|
return $response;
|
|
}
|
|
|
|
$viewer = $this->getViewer();
|
|
$drequest = $this->getDiffusionRequest();
|
|
$repository = $drequest->getRepository();
|
|
|
|
if (!$drequest->supportsBranches()) {
|
|
return $this->newDialog()
|
|
->setTitle(pht('No Ref Support'))
|
|
->appendParagraph(
|
|
pht(
|
|
'The version control system this repository uses does not '.
|
|
'support named references, so you can not resolve or list '.
|
|
'repository refs in this repository.'))
|
|
->addCancelButton($repository->getURI());
|
|
}
|
|
|
|
$ref_name = $drequest->getBranch();
|
|
|
|
$cache_query = id(new DiffusionCachedResolveRefsQuery())
|
|
->setRepository($repository);
|
|
if ($ref_name !== null) {
|
|
$cache_query->withRefs(array($ref_name));
|
|
}
|
|
$cache_refs = $cache_query->execute();
|
|
|
|
$vcs_refs = DiffusionQuery::callConduitWithDiffusionRequest(
|
|
$viewer,
|
|
$drequest,
|
|
'diffusion.resolverefs',
|
|
array(
|
|
'refs' => array($ref_name),
|
|
));
|
|
|
|
$all = array();
|
|
foreach ($cache_refs as $ref => $results) {
|
|
foreach ($results as $result) {
|
|
$id = $result['type'].'/'.$result['identifier'];
|
|
$all[$ref][$id]['cache'] = $result;
|
|
}
|
|
}
|
|
|
|
foreach ($vcs_refs as $ref => $results) {
|
|
foreach ($results as $result) {
|
|
$id = $result['type'].'/'.$result['identifier'];
|
|
$all[$ref][$id]['vcs'] = $result;
|
|
}
|
|
}
|
|
|
|
$rows = array();
|
|
foreach ($all as $ref => $results) {
|
|
foreach ($results as $info) {
|
|
$cache = idx($info, 'cache', array());
|
|
$vcs = idx($info, 'vcs', array());
|
|
|
|
$type = idx($vcs, 'type');
|
|
if (!$type) {
|
|
$type = idx($cache, 'type');
|
|
}
|
|
|
|
$hash = idx($vcs, 'identifier');
|
|
if ($hash !== null) {
|
|
$hash = DiffusionView::linkCommit(
|
|
$repository,
|
|
$hash);
|
|
}
|
|
|
|
$cached_hash = idx($cache, 'identifier');
|
|
if ($cached_hash !== null) {
|
|
$cached_hash = DiffusionView::linkCommit(
|
|
$repository,
|
|
$cached_hash);
|
|
}
|
|
|
|
$closed = idx($vcs, 'closed', false);
|
|
if (!$vcs) {
|
|
$state = null;
|
|
} else {
|
|
$state = $closed ? pht('Closed') : pht('Open');
|
|
}
|
|
|
|
$cached_closed = idx($cache, 'closed', false);
|
|
if (!$cache) {
|
|
$cached_state = null;
|
|
} else {
|
|
$cached_state = $cached_closed ? pht('Closed') : pht('Open');
|
|
}
|
|
|
|
$alternate = idx($vcs, 'alternate');
|
|
if ($alternate !== null) {
|
|
$alternate = DiffusionView::linkCommit(
|
|
$repository,
|
|
$alternate);
|
|
}
|
|
|
|
$rows[] = array(
|
|
$ref,
|
|
$type,
|
|
$hash,
|
|
$cached_hash,
|
|
$state,
|
|
$cached_state,
|
|
$alternate,
|
|
);
|
|
}
|
|
}
|
|
|
|
$table = id(new AphrontTableView($rows))
|
|
->setHeaders(
|
|
array(
|
|
pht('Ref'),
|
|
pht('Type'),
|
|
pht('Hash'),
|
|
pht('Cached Hash'),
|
|
pht('State'),
|
|
pht('Cached State'),
|
|
pht('Alternate'),
|
|
));
|
|
|
|
$content = id(new PHUIObjectBoxView())
|
|
->setHeaderText(pht('Ref "%s"', $ref_name))
|
|
->setTable($table);
|
|
|
|
$crumbs = $this->buildCrumbs(array());
|
|
$crumbs->addTextCrumb(pht('Refs'));
|
|
|
|
return $this->newPage()
|
|
->setTitle(
|
|
array(
|
|
$ref_name,
|
|
pht('Ref'),
|
|
$repository->getDisplayName(),
|
|
))
|
|
->setCrumbs($crumbs)
|
|
->appendChild($content);
|
|
}
|
|
|
|
}
|