2011-04-04 04:20:47 +02:00
|
|
|
<?php
|
|
|
|
|
2012-03-10 00:46:25 +01:00
|
|
|
final class DiffusionPathCompleteController 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();
|
|
|
|
|
2011-04-04 04:20:47 +02:00
|
|
|
$query_path = $request->getStr('q');
|
|
|
|
if (preg_match('@/$@', $query_path)) {
|
|
|
|
$query_dir = $query_path;
|
|
|
|
} else {
|
2012-07-16 21:44:14 +02:00
|
|
|
$query_dir = dirname($query_path).'/';
|
2011-04-04 04:20:47 +02:00
|
|
|
}
|
2012-07-16 21:44:14 +02:00
|
|
|
$query_dir = ltrim($query_dir, '/');
|
2011-04-04 04:20:47 +02:00
|
|
|
|
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' => $query_dir,
|
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(),
|
|
|
|
)));
|
|
|
|
$paths = $browse_results->getPaths();
|
2011-04-04 04:20:47 +02:00
|
|
|
|
|
|
|
$output = array();
|
|
|
|
foreach ($paths as $path) {
|
|
|
|
$full_path = $query_dir.$path->getPath();
|
|
|
|
if ($path->getFileType() == DifferentialChangeType::FILE_DIRECTORY) {
|
|
|
|
$full_path .= '/';
|
|
|
|
}
|
|
|
|
$output[] = array('/'.$full_path, null, substr(md5($full_path), 0, 7));
|
|
|
|
}
|
|
|
|
|
|
|
|
return id(new AphrontAjaxResponse())->setContent($output);
|
|
|
|
}
|
|
|
|
}
|