Support slightly prettier repository URIs in Diffusion
Summary: Fixes T4245. When a repository has a short name, use `/source/shortname/` as its primary URI. Test Plan: - Cloned Git repositories from shortnames via HTTP and SSH. - Cloned Mercurial repositories from shortnames via HTTP and SSH. - Cloned Subversion repositories from shortnames via SSH. - Browsed Git, Mercurial and Subversion repositories. - Added and removed short names to various repositories. Reviewers: chad Reviewed By: chad Maniphest Tasks: T4245 Differential Revision: https://secure.phabricator.com/D16851
This commit is contained in:
@@ -90,6 +90,11 @@ abstract class DiffusionController extends PhabricatorController {
|
||||
protected function getRepositoryIdentifierFromRequest(
|
||||
AphrontRequest $request) {
|
||||
|
||||
$short_name = $request->getURIData('repositoryShortName');
|
||||
if (strlen($short_name)) {
|
||||
return $short_name;
|
||||
}
|
||||
|
||||
$identifier = $request->getURIData('repositoryCallsign');
|
||||
if (strlen($identifier)) {
|
||||
return $identifier;
|
||||
|
||||
@@ -16,6 +16,7 @@ final class DiffusionLastModifiedController extends DiffusionController {
|
||||
$drequest = $this->getDiffusionRequest();
|
||||
|
||||
$paths = $request->getStr('paths');
|
||||
|
||||
try {
|
||||
$paths = phutil_json_decode($paths);
|
||||
} catch (PhutilJSONParserException $ex) {
|
||||
|
||||
@@ -88,6 +88,13 @@ final class DiffusionServeController extends DiffusionController {
|
||||
}
|
||||
}
|
||||
|
||||
// If the request was for a path like "/source/libphutil.git" but the
|
||||
// repository is not a Git repository, reject the request.
|
||||
$type_git = PhabricatorRepositoryType::REPOSITORY_TYPE_GIT;
|
||||
if ($request->getURIData('dotgit') && ($vcs !== $type_git)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $vcs;
|
||||
}
|
||||
|
||||
@@ -607,7 +614,9 @@ final class DiffusionServeController extends DiffusionController {
|
||||
$request = $this->getRequest();
|
||||
$request_path = $request->getRequestURI()->getPath();
|
||||
|
||||
$info = PhabricatorRepository::parseRepositoryServicePath($request_path);
|
||||
$info = PhabricatorRepository::parseRepositoryServicePath(
|
||||
$request_path,
|
||||
$repository->getVersionControlSystem());
|
||||
$base_path = $info['path'];
|
||||
|
||||
// For Git repositories, strip an optional directory component if it
|
||||
|
||||
Reference in New Issue
Block a user