mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-13 09:06:14 +01:00
3cbc239bc6
Summary: Ref T4245. This gets everything else except serving HTTP requests (complicated) and lint (quite weird). Test Plan: - Viewed a diff. - Viewed externals. - Viewed history table to see last modified. - Did path completion and validation in Owners. - Did tree path search in Diffusion. - Viewed a repository. - Created a new repository. - Looked up symbols. Reviewers: chad Reviewed By: chad Maniphest Tasks: T4245 Differential Revision: https://secure.phabricator.com/D14947
63 lines
1.6 KiB
PHP
63 lines
1.6 KiB
PHP
<?php
|
|
|
|
final class DiffusionPathValidateController extends DiffusionController {
|
|
|
|
protected function getRepositoryIdentifierFromRequest(
|
|
AphrontRequest $request) {
|
|
return $request->getStr('repositoryPHID');
|
|
}
|
|
|
|
public function handleRequest(AphrontRequest $request) {
|
|
$response = $this->loadDiffusionContext();
|
|
if ($response) {
|
|
return $response;
|
|
}
|
|
|
|
$viewer = $this->getViewer();
|
|
$drequest = $this->getDiffusionRequest();
|
|
$repository = $drequest->getRepository();
|
|
|
|
$path = $request->getStr('path');
|
|
$path = ltrim($path, '/');
|
|
|
|
$browse_results = DiffusionBrowseResultSet::newFromConduit(
|
|
$this->callConduitWithDiffusionRequest(
|
|
'diffusion.browsequery',
|
|
array(
|
|
'path' => $path,
|
|
'commit' => $drequest->getCommit(),
|
|
'needValidityOnly' => true,
|
|
)));
|
|
$valid = $browse_results->isValidResults();
|
|
|
|
if (!$valid) {
|
|
switch ($browse_results->getReasonForEmptyResultSet()) {
|
|
case DiffusionBrowseResultSet::REASON_IS_FILE:
|
|
$valid = true;
|
|
break;
|
|
case DiffusionBrowseResultSet::REASON_IS_EMPTY:
|
|
$valid = true;
|
|
break;
|
|
}
|
|
}
|
|
|
|
$output = array(
|
|
'valid' => (bool)$valid,
|
|
);
|
|
|
|
if (!$valid) {
|
|
$branch = $drequest->getBranch();
|
|
if ($branch) {
|
|
$message = pht('Not found in %s', $branch);
|
|
} else {
|
|
$message = pht('Not found at %s', 'HEAD');
|
|
}
|
|
} else {
|
|
$message = pht('OK');
|
|
}
|
|
|
|
$output['message'] = $message;
|
|
|
|
return id(new AphrontAjaxResponse())->setContent($output);
|
|
}
|
|
}
|