Differential D18439 Diff 44306 src/applications/diffusion/controller/DiffusionRepositoryController.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/diffusion/controller/DiffusionRepositoryController.php
Show All 28 Lines | public function handleRequest(AphrontRequest $request) { | ||||
$header = $this->buildHeaderView($repository); | $header = $this->buildHeaderView($repository); | ||||
$actions = $this->buildActionList($repository); | $actions = $this->buildActionList($repository); | ||||
$description = $this->buildDescriptionView($repository); | $description = $this->buildDescriptionView($repository); | ||||
$locate_file = $this->buildLocateFile(); | $locate_file = $this->buildLocateFile(); | ||||
// Before we do any work, make sure we're looking at a some content: we're | // Before we do any work, make sure we're looking at a some content: we're | ||||
// on a valid branch, and the repository is not empty. | // on a valid branch, and the repository is not empty. | ||||
$page_has_content = false; | $page_has_content = false; | ||||
$empty_title = null; | $notices = array(); | ||||
$empty_message = null; | |||||
if (!$repository->isTracked()) { | |||||
$notices[] = id(new PHUIInfoView()) | |||||
->setSeverity(PHUIInfoView::SEVERITY_ERROR) | |||||
->setTitle(pht('Not Activated')) | |||||
->appendChild(pht('This repository is not currently active. You can '. | |||||
're-enable it under "Manage Repository".')); | |||||
} | |||||
// If this VCS supports branches, check that the selected branch actually | // If this VCS supports branches, check that the selected branch actually | ||||
// exists. | // exists. | ||||
if ($drequest->supportsBranches()) { | if ($drequest->supportsBranches()) { | ||||
$tracking = $repository->shouldTrackBranch($drequest->getBranch()); | |||||
// NOTE: Mercurial may have multiple branch heads with the same name. | // NOTE: Mercurial may have multiple branch heads with the same name. | ||||
$ref_cursors = id(new PhabricatorRepositoryRefCursorQuery()) | $ref_cursors = id(new PhabricatorRepositoryRefCursorQuery()) | ||||
->setViewer($viewer) | ->setViewer($viewer) | ||||
->withRepositoryPHIDs(array($repository->getPHID())) | ->withRepositoryPHIDs(array($repository->getPHID())) | ||||
->withRefTypes(array(PhabricatorRepositoryRefCursor::TYPE_BRANCH)) | ->withRefTypes(array(PhabricatorRepositoryRefCursor::TYPE_BRANCH)) | ||||
->withRefNames(array($drequest->getBranch())) | ->withRefNames(array($drequest->getBranch())) | ||||
->execute(); | ->execute(); | ||||
if ($ref_cursors) { | if ($ref_cursors && $tracking) { | ||||
// This is a valid branch, so we necessarily have some content. | // This is a valid branch, so we necessarily have some content. | ||||
$page_has_content = true; | $page_has_content = true; | ||||
} else { | |||||
$default = $repository->getDefaultBranch(); | |||||
if ($default != $drequest->getBranch()) { | |||||
$empty_title = pht('No Such Branch'); | |||||
$empty_message = pht( | |||||
'There is no branch named "%s" in this repository.', | |||||
$drequest->getBranch()); | |||||
} else { | |||||
$empty_title = pht('No Default Branch'); | |||||
$empty_message = pht( | |||||
'This repository is configured with default branch "%s" but '. | |||||
'there is no branch with that name in this repository.', | |||||
$default); | |||||
} | |||||
} | } | ||||
} | } | ||||
chad: I think this if statement is never hit. Unsure what the intent of the task was, maybe this case… | |||||
// If we didn't find any branches, check if there are any commits at all. | // If we didn't find any branches, check if there are any commits at all. | ||||
// This can tailor the message for empty repositories. | // This can tailor the message for empty repositories. | ||||
$any_commit = null; | $any_commit = null; | ||||
if (!$page_has_content) { | if (!$page_has_content) { | ||||
$any_commit = id(new DiffusionCommitQuery()) | $any_commit = id(new DiffusionCommitQuery()) | ||||
->setViewer($viewer) | ->setViewer($viewer) | ||||
->withRepository($repository) | ->withRepository($repository) | ||||
->setLimit(1) | ->setLimit(1) | ||||
->execute(); | ->execute(); | ||||
if ($any_commit) { | if ($any_commit) { | ||||
// Subversion | |||||
if (!$drequest->supportsBranches()) { | if (!$drequest->supportsBranches()) { | ||||
$page_has_content = true; | $page_has_content = true; | ||||
} | } | ||||
$default = $repository->getDefaultBranch(); | |||||
$tracking = $repository->shouldTrackBranch($drequest->getBranch()); | |||||
if (!$tracking) { | |||||
$page_has_content = false; | |||||
$notices[] = id(new PHUIInfoView()) | |||||
->setSeverity(PHUIInfoView::SEVERITY_WARNING) | |||||
->setTitle('Not Tracked') | |||||
->appendChild(pht('The branch "%s" is not being tracked. You can '. | |||||
'enable tracking under "Branches" in "Manage Repository".', | |||||
$drequest->getBranch())); | |||||
} else if ($default != $drequest->getBranch()) { | |||||
$notices[] = id(new PHUIInfoView()) | |||||
->setSeverity(PHUIInfoView::SEVERITY_WARNING) | |||||
->setTitle(pht('No Such Branch')) | |||||
->appendChild( | |||||
pht( | |||||
'There is no branch named "%s" in this repository.', | |||||
$drequest->getBranch())); | |||||
} else { | } else { | ||||
$empty_title = pht('Empty Repository'); | $notices[] = id(new PHUIInfoView()) | ||||
$empty_message = pht('This repository does not have any commits yet.'); | ->setSeverity(PHUIInfoView::SEVERITY_WARNING) | ||||
->setTitle(pht('No Default Branch')) | |||||
->appendChild( | |||||
pht( | |||||
'This repository is configured with default branch "%s" but '. | |||||
'there is no branch with that name in this repository.', | |||||
$default)); | |||||
} | |||||
} else { | |||||
$notices[] = id(new PHUIInfoView()) | |||||
->setSeverity(PHUIInfoView::SEVERITY_NOTICE) | |||||
->setTitle('No Commits') | |||||
->appendChild(pht('This repository does not have any commits yet.')); | |||||
} | } | ||||
} | } | ||||
if ($page_has_content) { | if ($page_has_content) { | ||||
$content = $this->buildNormalContent($drequest); | $content = $this->buildNormalContent($drequest); | ||||
} else { | } else { | ||||
// If we have a commit somewhere, find branches. | // If we have a commit somewhere, find branches. | ||||
// TODO: Evan will replace | // TODO: Evan will replace | ||||
// $this->buildNormalContent($drequest); | // $this->buildNormalContent($drequest); | ||||
$content = id(new PHUIInfoView()) | $content = null; | ||||
->setTitle($empty_title) | |||||
->setSeverity(PHUIInfoView::SEVERITY_WARNING) | |||||
->setErrors(array($empty_message)); | |||||
} | } | ||||
$tabs = $this->buildTabsView('code'); | $tabs = $this->buildTabsView('code'); | ||||
$clone_uri = $drequest->generateURI( | $clone_uri = $drequest->generateURI( | ||||
array( | array( | ||||
'action' => 'clone', | 'action' => 'clone', | ||||
)); | )); | ||||
Show All 25 Lines | $bar = id(new PHUILeftRightView()) | ||||
->setLeft($locate_file) | ->setLeft($locate_file) | ||||
->setRight(array($this->branchButton, $actions_button, $clone_button)) | ->setRight(array($this->branchButton, $actions_button, $clone_button)) | ||||
->addClass('diffusion-action-bar'); | ->addClass('diffusion-action-bar'); | ||||
$view = id(new PHUITwoColumnView()) | $view = id(new PHUITwoColumnView()) | ||||
->setHeader($header) | ->setHeader($header) | ||||
->setFooter(array( | ->setFooter(array( | ||||
$bar, | $bar, | ||||
$notices, | |||||
$description, | $description, | ||||
$content, | $content, | ||||
)); | )); | ||||
if ($page_has_content) { | if ($page_has_content) { | ||||
$view->setTabs($tabs); | $view->setTabs($tabs); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 450 Lines • Show Last 20 Lines |
I think this if statement is never hit. Unsure what the intent of the task was, maybe this case is not possible.