1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-27 01:02:42 +01:00

Fix error for URL's that could mean several commits

Summary: Ref T13001, URLs that return multiple commits should show a list of those commits. Not sure if the actual list looks very pretty this way, but was wondering if this approach was vaguely correct.

Test Plan:
- Navigate to `install/rPbd3c23`
- User should see a list view providing links to `install/rPbd3c2355e8e2b220ae5e3cbfe4a057c8088c6a38` and `install/rPbd3c239d5aada68a31db5742bbb8ec099074a561`

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: Korvin

Maniphest Tasks: T13001

Differential Revision: https://secure.phabricator.com/D18816
This commit is contained in:
lkassianik 2017-12-05 19:24:57 +00:00 committed by lpriestley
parent c924351a58
commit 46d496b8cc

View file

@ -39,20 +39,23 @@ final class DiffusionCommitController extends DiffusionController {
return $this->buildRawDiffResponse($drequest); return $this->buildRawDiffResponse($drequest);
} }
$commit = id(new DiffusionCommitQuery()) $commits = id(new DiffusionCommitQuery())
->setViewer($viewer) ->setViewer($viewer)
->withRepository($repository) ->withRepository($repository)
->withIdentifiers(array($commit_identifier)) ->withIdentifiers(array($commit_identifier))
->needCommitData(true) ->needCommitData(true)
->needAuditRequests(true) ->needAuditRequests(true)
->executeOne(); ->setLimit(100)
->execute();
$multiple_results = count($commits) > 1;
$crumbs = $this->buildCrumbs(array( $crumbs = $this->buildCrumbs(array(
'commit' => true, 'commit' => !$multiple_results,
)); ));
$crumbs->setBorder(true); $crumbs->setBorder(true);
if (!$commit) { if (!$commits) {
if (!$this->getCommitExists()) { if (!$this->getCommitExists()) {
return new Aphront404Response(); return new Aphront404Response();
} }
@ -70,7 +73,40 @@ final class DiffusionCommitController extends DiffusionController {
->setTitle($title) ->setTitle($title)
->setCrumbs($crumbs) ->setCrumbs($crumbs)
->appendChild($error); ->appendChild($error);
} else if ($multiple_results) {
$warning_message =
pht(
'The identifier %s is ambiguous and matches more than one commit.',
phutil_tag(
'strong',
array(),
$commit_identifier));
$error = id(new PHUIInfoView())
->setTitle(pht('Ambiguous Commit'))
->setSeverity(PHUIInfoView::SEVERITY_WARNING)
->appendChild($warning_message);
$list = id(new DiffusionCommitListView())
->setViewer($viewer)
->setCommits($commits)
->setNoDataString(pht('No recent commits.'));
$crumbs->addTextCrumb(pht('Ambiguous Commit'));
$matched_commits = id(new PHUITwoColumnView())
->setFooter(array(
$error,
$list,
));
return $this->newPage()
->setTitle(pht('Ambiguous Commit'))
->setCrumbs($crumbs)
->appendChild($matched_commits);
} else {
$commit = head($commits);
} }
$audit_requests = $commit->getAudits(); $audit_requests = $commit->getAudits();