2011-04-04 04:20:47 +02:00
|
|
|
<?php
|
|
|
|
|
2012-03-10 00:46:25 +01:00
|
|
|
final class DiffusionPathValidateController extends DiffusionController {
|
2011-04-04 04:20:47 +02:00
|
|
|
|
2016-01-05 19:34:04 +01:00
|
|
|
protected function getRepositoryIdentifierFromRequest(
|
|
|
|
AphrontRequest $request) {
|
|
|
|
return $request->getStr('repositoryPHID');
|
2011-04-04 04:20:47 +02:00
|
|
|
}
|
|
|
|
|
2016-01-05 19:34:04 +01:00
|
|
|
public function handleRequest(AphrontRequest $request) {
|
|
|
|
$response = $this->loadDiffusionContext();
|
|
|
|
if ($response) {
|
|
|
|
return $response;
|
2011-04-04 04:20:47 +02:00
|
|
|
}
|
|
|
|
|
2016-01-05 19:34:04 +01:00
|
|
|
$viewer = $this->getViewer();
|
|
|
|
$drequest = $this->getDiffusionRequest();
|
|
|
|
$repository = $drequest->getRepository();
|
|
|
|
|
2011-04-04 04:20:47 +02:00
|
|
|
$path = $request->getStr('path');
|
|
|
|
$path = ltrim($path, '/');
|
|
|
|
|
Diffusion - move DiffusionBrowseQuery => Conduit
Summary: see title. Ref T2784.
Test Plan:
In diffusion, for each of SVN, Mercurial, and Git, I loaded up /diffusion/CALLSIGN/. I verified the README was displayed and things looked good. Next I clicked on "browse" on the top-most commit and verified things looked correct. Also clicked through to a file for a good measure and things looked good.
In owners, for each of SVN, Mercurial, and Git, I played around with the path typeahead / validator. It worked correctly!
Reviewers: epriestley
Reviewed By: epriestley
CC: chad, aran, Korvin
Maniphest Tasks: T2784
Differential Revision: https://secure.phabricator.com/D5883
2013-05-10 20:02:58 +02:00
|
|
|
$browse_results = DiffusionBrowseResultSet::newFromConduit(
|
|
|
|
$this->callConduitWithDiffusionRequest(
|
|
|
|
'diffusion.browsequery',
|
|
|
|
array(
|
2016-01-05 19:34:04 +01:00
|
|
|
'path' => $path,
|
Diffusion - move DiffusionBrowseQuery => Conduit
Summary: see title. Ref T2784.
Test Plan:
In diffusion, for each of SVN, Mercurial, and Git, I loaded up /diffusion/CALLSIGN/. I verified the README was displayed and things looked good. Next I clicked on "browse" on the top-most commit and verified things looked correct. Also clicked through to a file for a good measure and things looked good.
In owners, for each of SVN, Mercurial, and Git, I played around with the path typeahead / validator. It worked correctly!
Reviewers: epriestley
Reviewed By: epriestley
CC: chad, aran, Korvin
Maniphest Tasks: T2784
Differential Revision: https://secure.phabricator.com/D5883
2013-05-10 20:02:58 +02:00
|
|
|
'commit' => $drequest->getCommit(),
|
|
|
|
'needValidityOnly' => true,
|
|
|
|
)));
|
|
|
|
$valid = $browse_results->isValidResults();
|
2011-04-04 04:20:47 +02:00
|
|
|
|
|
|
|
if (!$valid) {
|
Diffusion - move DiffusionBrowseQuery => Conduit
Summary: see title. Ref T2784.
Test Plan:
In diffusion, for each of SVN, Mercurial, and Git, I loaded up /diffusion/CALLSIGN/. I verified the README was displayed and things looked good. Next I clicked on "browse" on the top-most commit and verified things looked correct. Also clicked through to a file for a good measure and things looked good.
In owners, for each of SVN, Mercurial, and Git, I played around with the path typeahead / validator. It worked correctly!
Reviewers: epriestley
Reviewed By: epriestley
CC: chad, aran, Korvin
Maniphest Tasks: T2784
Differential Revision: https://secure.phabricator.com/D5883
2013-05-10 20:02:58 +02:00
|
|
|
switch ($browse_results->getReasonForEmptyResultSet()) {
|
|
|
|
case DiffusionBrowseResultSet::REASON_IS_FILE:
|
2011-04-04 04:20:47 +02:00
|
|
|
$valid = true;
|
|
|
|
break;
|
Diffusion - move DiffusionBrowseQuery => Conduit
Summary: see title. Ref T2784.
Test Plan:
In diffusion, for each of SVN, Mercurial, and Git, I loaded up /diffusion/CALLSIGN/. I verified the README was displayed and things looked good. Next I clicked on "browse" on the top-most commit and verified things looked correct. Also clicked through to a file for a good measure and things looked good.
In owners, for each of SVN, Mercurial, and Git, I played around with the path typeahead / validator. It worked correctly!
Reviewers: epriestley
Reviewed By: epriestley
CC: chad, aran, Korvin
Maniphest Tasks: T2784
Differential Revision: https://secure.phabricator.com/D5883
2013-05-10 20:02:58 +02:00
|
|
|
case DiffusionBrowseResultSet::REASON_IS_EMPTY:
|
2011-04-04 04:20:47 +02:00
|
|
|
$valid = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$output = array(
|
|
|
|
'valid' => (bool)$valid,
|
|
|
|
);
|
|
|
|
|
|
|
|
if (!$valid) {
|
|
|
|
$branch = $drequest->getBranch();
|
|
|
|
if ($branch) {
|
2013-05-11 17:23:19 +02:00
|
|
|
$message = pht('Not found in %s', $branch);
|
2011-04-04 04:20:47 +02:00
|
|
|
} else {
|
2015-05-22 09:27:56 +02:00
|
|
|
$message = pht('Not found at %s', 'HEAD');
|
2011-04-04 04:20:47 +02:00
|
|
|
}
|
|
|
|
} else {
|
2013-05-11 17:23:19 +02:00
|
|
|
$message = pht('OK');
|
2011-04-04 04:20:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
$output['message'] = $message;
|
|
|
|
|
|
|
|
return id(new AphrontAjaxResponse())->setContent($output);
|
|
|
|
}
|
|
|
|
}
|