Changeset View
Changeset View
Standalone View
Standalone View
src/applications/repository/storage/PhabricatorRepository.php
Show First 20 Lines • Show All 436 Lines • ▼ Show 20 Lines | public static function assertValidRepositorySlug($slug) { | ||||
if (preg_match('/^\d+\z/', $slug)) { | if (preg_match('/^\d+\z/', $slug)) { | ||||
throw new Exception( | throw new Exception( | ||||
pht( | pht( | ||||
'The name "%s" is not a valid repository short name. Repository '. | 'The name "%s" is not a valid repository short name. Repository '. | ||||
'short names may not contain only numbers.', | 'short names may not contain only numbers.', | ||||
$slug)); | $slug)); | ||||
} | } | ||||
if (preg_match('/\\.git/', $slug)) { | |||||
throw new Exception( | |||||
pht( | |||||
'The name "%s" is not a valid repository short name. Repository '. | |||||
'short names must not end in ".git". This suffix will be added '. | |||||
'automatically in appropriate contexts.', | |||||
$slug)); | |||||
} | |||||
} | } | ||||
public static function assertValidCallsign($callsign) { | public static function assertValidCallsign($callsign) { | ||||
if (!strlen($callsign)) { | if (!strlen($callsign)) { | ||||
throw new Exception( | throw new Exception( | ||||
pht( | pht( | ||||
'A repository callsign must be at least one character long.')); | 'A repository callsign must be at least one character long.')); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 134 Lines • ▼ Show 20 Lines | if (strlen($callsign)) { | ||||
return "/r{$callsign}{$identifier}"; | return "/r{$callsign}{$identifier}"; | ||||
} | } | ||||
$id = $this->getID(); | $id = $this->getID(); | ||||
return "/R{$id}:{$identifier}"; | return "/R{$id}:{$identifier}"; | ||||
} | } | ||||
public static function parseRepositoryServicePath($request_path, $vcs) { | public static function parseRepositoryServicePath($request_path, $vcs) { | ||||
$is_git = ($vcs == PhabricatorRepositoryType::REPOSITORY_TYPE_GIT); | |||||
// NOTE: In Mercurial over SSH, the path will begin without a leading "/", | |||||
// so we're matching it optionally. | |||||
epriestley: I couldn't figure out what this was talking about after some probing, so I think we're fine. | |||||
if ($vcs == PhabricatorRepositoryType::REPOSITORY_TYPE_GIT) { | |||||
$maybe_git = '(?:\\.git)?'; | |||||
} else { | |||||
$maybe_git = null; | |||||
} | |||||
$patterns = array( | $patterns = array( | ||||
'(^'. | '(^'. | ||||
'(?P<base>/?(?:diffusion|source)/(?P<identifier>[^/.]+))'. | '(?P<base>/?(?:diffusion|source)/(?P<identifier>[^/]+))'. | ||||
$maybe_git. | '(?P<path>.*)'. | ||||
'(?P<path>(?:/|.*)?)'. | |||||
'\z)', | '\z)', | ||||
); | ); | ||||
$identifier = null; | $identifier = null; | ||||
foreach ($patterns as $pattern) { | foreach ($patterns as $pattern) { | ||||
$matches = null; | $matches = null; | ||||
if (!preg_match($pattern, $request_path, $matches)) { | if (!preg_match($pattern, $request_path, $matches)) { | ||||
continue; | continue; | ||||
} | } | ||||
$identifier = $matches['identifier']; | $identifier = $matches['identifier']; | ||||
if ($is_git) { | |||||
$identifier = preg_replace('/\\.git\z/', '', $identifier); | |||||
} | |||||
$base = $matches['base']; | $base = $matches['base']; | ||||
$path = $matches['path']; | $path = $matches['path']; | ||||
break; | break; | ||||
} | } | ||||
if ($identifier === null) { | if ($identifier === null) { | ||||
return null; | return null; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 1,827 Lines • Show Last 20 Lines |
I couldn't figure out what this was talking about after some probing, so I think we're fine. SSH clones with Mercurial definitely work. Possibly we haven't seen the end of this.