Path: blob/master/src/applications/diffusion/controller/DiffusionRefTableController.php
12242 views
<?php12final class DiffusionRefTableController extends DiffusionController {34public function shouldAllowPublic() {5return true;6}78public function handleRequest(AphrontRequest $request) {9$response = $this->loadDiffusionContext();10if ($response) {11return $response;12}1314$viewer = $this->getViewer();15$drequest = $this->getDiffusionRequest();16$repository = $drequest->getRepository();1718if (!$drequest->supportsBranches()) {19return $this->newDialog()20->setTitle(pht('No Ref Support'))21->appendParagraph(22pht(23'The version control system this repository uses does not '.24'support named references, so you can not resolve or list '.25'repository refs in this repository.'))26->addCancelButton($repository->getURI());27}2829$ref_name = $drequest->getBranch();3031$cache_query = id(new DiffusionCachedResolveRefsQuery())32->setRepository($repository);33if ($ref_name !== null) {34$cache_query->withRefs(array($ref_name));35}36$cache_refs = $cache_query->execute();3738$vcs_refs = DiffusionQuery::callConduitWithDiffusionRequest(39$viewer,40$drequest,41'diffusion.resolverefs',42array(43'refs' => array($ref_name),44));4546$all = array();47foreach ($cache_refs as $ref => $results) {48foreach ($results as $result) {49$id = $result['type'].'/'.$result['identifier'];50$all[$ref][$id]['cache'] = $result;51}52}5354foreach ($vcs_refs as $ref => $results) {55foreach ($results as $result) {56$id = $result['type'].'/'.$result['identifier'];57$all[$ref][$id]['vcs'] = $result;58}59}6061$rows = array();62foreach ($all as $ref => $results) {63foreach ($results as $info) {64$cache = idx($info, 'cache', array());65$vcs = idx($info, 'vcs', array());6667$type = idx($vcs, 'type');68if (!$type) {69$type = idx($cache, 'type');70}7172$hash = idx($vcs, 'identifier');73if ($hash !== null) {74$hash = DiffusionView::linkCommit(75$repository,76$hash);77}7879$cached_hash = idx($cache, 'identifier');80if ($cached_hash !== null) {81$cached_hash = DiffusionView::linkCommit(82$repository,83$cached_hash);84}8586$closed = idx($vcs, 'closed', false);87if (!$vcs) {88$state = null;89} else {90$state = $closed ? pht('Closed') : pht('Open');91}9293$cached_closed = idx($cache, 'closed', false);94if (!$cache) {95$cached_state = null;96} else {97$cached_state = $cached_closed ? pht('Closed') : pht('Open');98}99100$alternate = idx($vcs, 'alternate');101if ($alternate !== null) {102$alternate = DiffusionView::linkCommit(103$repository,104$alternate);105}106107$rows[] = array(108$ref,109$type,110$hash,111$cached_hash,112$state,113$cached_state,114$alternate,115);116}117}118119$table = id(new AphrontTableView($rows))120->setHeaders(121array(122pht('Ref'),123pht('Type'),124pht('Hash'),125pht('Cached Hash'),126pht('State'),127pht('Cached State'),128pht('Alternate'),129));130131$content = id(new PHUIObjectBoxView())132->setHeaderText(pht('Ref "%s"', $ref_name))133->setTable($table);134135$crumbs = $this->buildCrumbs(array());136$crumbs->addTextCrumb(pht('Refs'));137138return $this->newPage()139->setTitle(140array(141$ref_name,142pht('Ref'),143$repository->getDisplayName(),144))145->setCrumbs($crumbs)146->appendChild($content);147}148149}150151152