diff --git a/src/applications/diffusion/controller/DiffusionBranchTableController.php b/src/applications/diffusion/controller/DiffusionBranchTableController.php index a040c8084e..3a025e90c5 100644 --- a/src/applications/diffusion/controller/DiffusionBranchTableController.php +++ b/src/applications/diffusion/controller/DiffusionBranchTableController.php @@ -1,79 +1,85 @@ loadDiffusionContext(); if ($response) { return $response; } $viewer = $this->getViewer(); $drequest = $this->getDiffusionRequest(); $repository = $drequest->getRepository(); $pager = id(new PHUIPagerView()) ->readFromRequest($request); - // TODO: Add support for branches that contain commit + $params = array( + 'offset' => $pager->getOffset(), + 'limit' => $pager->getPageSize() + 1, + ); + + $contains = $drequest->getSymbolicCommit(); + if (strlen($contains)) { + $params['contains'] = $contains; + } + $branches = $this->callConduitWithDiffusionRequest( 'diffusion.branchquery', - array( - 'offset' => $pager->getOffset(), - 'limit' => $pager->getPageSize() + 1, - )); + $params); $branches = $pager->sliceResults($branches); $branches = DiffusionRepositoryRef::loadAllFromDictionaries($branches); $content = null; if (!$branches) { $content = $this->renderStatusMessage( pht('No Branches'), pht('This repository has no branches.')); } else { $commits = id(new DiffusionCommitQuery()) ->setViewer($viewer) ->withIdentifiers(mpull($branches, 'getCommitIdentifier')) ->withRepository($repository) ->execute(); $view = id(new DiffusionBranchTableView()) ->setUser($viewer) ->setBranches($branches) ->setCommits($commits) ->setDiffusionRequest($drequest); $panel = id(new PHUIObjectBoxView()) ->setHeaderText(pht('Branches')) ->setTable($view); $content = $panel; } $crumbs = $this->buildCrumbs( array( 'branches' => true, )); $pager_box = $this->renderTablePagerBox($pager); return $this->newPage() ->setTitle( array( pht('Branches'), $repository->getDisplayName(), )) ->setCrumbs($crumbs) ->appendChild( array( $content, $pager_box, )); } } diff --git a/src/applications/diffusion/controller/DiffusionCommitBranchesController.php b/src/applications/diffusion/controller/DiffusionCommitBranchesController.php index 1e5cc0ac31..e698ff6fc7 100644 --- a/src/applications/diffusion/controller/DiffusionCommitBranchesController.php +++ b/src/applications/diffusion/controller/DiffusionCommitBranchesController.php @@ -1,49 +1,59 @@ loadDiffusionContext(); if ($response) { return $response; } $drequest = $this->getDiffusionRequest(); $repository = $drequest->getRepository(); - switch ($repository->getVersionControlSystem()) { - case PhabricatorRepositoryType::REPOSITORY_TYPE_SVN: - $branches = array(); - break; - default: - $branches = $this->callConduitWithDiffusionRequest( - 'diffusion.branchquery', - array( - 'contains' => $drequest->getCommit(), - )); - break; - } + $branch_limit = 10; + $branches = DiffusionRepositoryRef::loadAllFromDictionaries( + $this->callConduitWithDiffusionRequest( + 'diffusion.branchquery', + array( + 'contains' => $drequest->getCommit(), + 'limit' => $branch_limit + 1, + ))); + + $has_more_branches = (count($branches) > $branch_limit); + $branches = array_slice($branches, 0, $branch_limit); - $branches = DiffusionRepositoryRef::loadAllFromDictionaries($branches); $branch_links = array(); foreach ($branches as $branch) { $branch_links[] = phutil_tag( 'a', array( 'href' => $drequest->generateURI( array( 'action' => 'browse', 'branch' => $branch->getShortName(), )), ), $branch->getShortName()); } + if ($has_more_branches) { + $branch_links[] = phutil_tag( + 'a', + array( + 'href' => $drequest->generateURI( + array( + 'action' => 'branches', + )), + ), + pht("More Branches\xE2\x80\xA6")); + } + return id(new AphrontAjaxResponse()) ->setContent($branch_links ? implode(', ', $branch_links) : pht('None')); } } diff --git a/src/applications/diffusion/controller/DiffusionCommitTagsController.php b/src/applications/diffusion/controller/DiffusionCommitTagsController.php index 0f825a9b64..aef73dd842 100644 --- a/src/applications/diffusion/controller/DiffusionCommitTagsController.php +++ b/src/applications/diffusion/controller/DiffusionCommitTagsController.php @@ -1,65 +1,59 @@ loadDiffusionContext(); if ($response) { return $response; } $drequest = $this->getDiffusionRequest(); $repository = $drequest->getRepository(); $tag_limit = 10; - switch ($repository->getVersionControlSystem()) { - case PhabricatorRepositoryType::REPOSITORY_TYPE_SVN: - $tags = array(); - break; - default: - $tags = DiffusionRepositoryTag::newFromConduit( - $this->callConduitWithDiffusionRequest( - 'diffusion.tagsquery', - array( - 'commit' => $drequest->getCommit(), - 'limit' => $tag_limit + 1, - ))); - break; - } + $tags = DiffusionRepositoryTag::newFromConduit( + $this->callConduitWithDiffusionRequest( + 'diffusion.tagsquery', + array( + 'commit' => $drequest->getCommit(), + 'limit' => $tag_limit + 1, + ))); + $has_more_tags = (count($tags) > $tag_limit); $tags = array_slice($tags, 0, $tag_limit); $tag_links = array(); foreach ($tags as $tag) { $tag_links[] = phutil_tag( 'a', array( 'href' => $drequest->generateURI( array( 'action' => 'browse', 'commit' => $tag->getName(), )), ), $tag->getName()); } if ($has_more_tags) { $tag_links[] = phutil_tag( 'a', array( 'href' => $drequest->generateURI( array( 'action' => 'tags', )), ), pht("More Tags\xE2\x80\xA6")); } return id(new AphrontAjaxResponse()) ->setContent($tag_links ? implode(', ', $tag_links) : pht('None')); } }