Changeset View
Changeset View
Standalone View
Standalone View
src/applications/repository/storage/PhabricatorRepository.php
Show First 20 Lines • Show All 275 Lines • ▼ Show 20 Lines | return $drequest->generateURI( | ||||
array( | array( | ||||
'action' => 'browse', | 'action' => 'browse', | ||||
'line' => $line, | 'line' => $line, | ||||
)); | )); | ||||
} | } | ||||
public function getSubversionBaseURI($commit = null) { | public function getSubversionBaseURI($commit = null) { | ||||
$subpath = $this->getDetail('svn-subpath'); | $subpath = $this->getDetail('svn-subpath'); | ||||
if (!strlen($subpath)) { | |||||
if (!phutil_nonempty_string($subpath)) { | |||||
$subpath = null; | $subpath = null; | ||||
} | } | ||||
return $this->getSubversionPathURI($subpath, $commit); | return $this->getSubversionPathURI($subpath, $commit); | ||||
} | } | ||||
public function getSubversionPathURI($path = null, $commit = null) { | public function getSubversionPathURI($path = null, $commit = null) { | ||||
$vcs = $this->getVersionControlSystem(); | $vcs = $this->getVersionControlSystem(); | ||||
if ($vcs != PhabricatorRepositoryType::REPOSITORY_TYPE_SVN) { | if ($vcs != PhabricatorRepositoryType::REPOSITORY_TYPE_SVN) { | ||||
throw new Exception(pht('Not a subversion repository!')); | throw new Exception(pht('Not a subversion repository!')); | ||||
} | } | ||||
if ($this->isHosted()) { | if ($this->isHosted()) { | ||||
$uri = 'file://'.$this->getLocalPath(); | $uri = 'file://'.$this->getLocalPath(); | ||||
} else { | } else { | ||||
$uri = $this->getDetail('remote-uri'); | $uri = $this->getDetail('remote-uri'); | ||||
} | } | ||||
$uri = rtrim($uri, '/'); | $uri = rtrim($uri, '/'); | ||||
if (strlen($path)) { | if (phutil_nonempty_string($path)) { | ||||
$path = rawurlencode($path); | $path = rawurlencode($path); | ||||
$path = str_replace('%2F', '/', $path); | $path = str_replace('%2F', '/', $path); | ||||
$uri = $uri.'/'.ltrim($path, '/'); | $uri = $uri.'/'.ltrim($path, '/'); | ||||
} | } | ||||
if ($path !== null || $commit !== null) { | if ($path !== null || $commit !== null) { | ||||
$uri .= '@'; | $uri .= '@'; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 256 Lines • ▼ Show 20 Lines | if ($this->usesLocalWorkingCopy()) { | ||||
$future->setCWD($this->getLocalPath()); | $future->setCWD($this->getLocalPath()); | ||||
} | } | ||||
return $future; | return $future; | ||||
} | } | ||||
public function getURI() { | public function getURI() { | ||||
$short_name = $this->getRepositorySlug(); | $short_name = $this->getRepositorySlug(); | ||||
if (strlen($short_name)) { | if (phutil_nonempty_string($short_name)) { | ||||
return "/source/{$short_name}/"; | return "/source/{$short_name}/"; | ||||
} | } | ||||
$callsign = $this->getCallsign(); | $callsign = $this->getCallsign(); | ||||
if (strlen($callsign)) { | if (phutil_nonempty_string($callsign)) { | ||||
return "/diffusion/{$callsign}/"; | return "/diffusion/{$callsign}/"; | ||||
} | } | ||||
$id = $this->getID(); | $id = $this->getID(); | ||||
return "/diffusion/{$id}/"; | return "/diffusion/{$id}/"; | ||||
} | } | ||||
public function getPathURI($path) { | public function getPathURI($path) { | ||||
return $this->getURI().ltrim($path, '/'); | return $this->getURI().ltrim($path, '/'); | ||||
} | } | ||||
public function getCommitURI($identifier) { | public function getCommitURI($identifier) { | ||||
$callsign = $this->getCallsign(); | $callsign = $this->getCallsign(); | ||||
if (strlen($callsign)) { | if (phutil_nonempty_string($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) { | ||||
▲ Show 20 Lines • Show All 126 Lines • ▼ Show 20 Lines | if ($req_branch && !strlen($branch)) { | ||||
'Diffusion URI action "%s" requires branch!', | 'Diffusion URI action "%s" requires branch!', | ||||
$action)); | $action)); | ||||
} | } | ||||
if ($action === 'commit') { | if ($action === 'commit') { | ||||
return $this->getCommitURI($commit); | return $this->getCommitURI($commit); | ||||
} | } | ||||
if (strlen($path)) { | if (phutil_nonempty_string($path)) { | ||||
$path = ltrim($path, '/'); | $path = ltrim($path, '/'); | ||||
$path = str_replace(array(';', '$'), array(';;', '$$'), $path); | $path = str_replace(array(';', '$'), array(';;', '$$'), $path); | ||||
$path = phutil_escape_uri($path); | $path = phutil_escape_uri($path); | ||||
} | } | ||||
$raw_branch = $branch; | $raw_branch = $branch; | ||||
if (strlen($branch)) { | if (phutil_nonempty_string($branch)) { | ||||
$branch = phutil_escape_uri_path_component($branch); | $branch = phutil_escape_uri_path_component($branch); | ||||
$path = "{$branch}/{$path}"; | $path = "{$branch}/{$path}"; | ||||
} | } | ||||
$raw_commit = $commit; | $raw_commit = $commit; | ||||
if (strlen($commit)) { | if (phutil_nonempty_string($commit)) { | ||||
$commit = str_replace('$', '$$', $commit); | $commit = str_replace('$', '$$', $commit); | ||||
$commit = ';'.phutil_escape_uri($commit); | $commit = ';'.phutil_escape_uri($commit); | ||||
} | } | ||||
if (strlen($line)) { | if (phutil_nonempty_string($line)) { | ||||
$line = '$'.phutil_escape_uri($line); | $line = '$'.phutil_escape_uri($line); | ||||
} | } | ||||
$query = array(); | $query = array(); | ||||
switch ($action) { | switch ($action) { | ||||
case 'change': | case 'change': | ||||
case 'history': | case 'history': | ||||
case 'blame': | case 'blame': | ||||
▲ Show 20 Lines • Show All 91 Lines • ▼ Show 20 Lines | if (!$spec) { | ||||
$spec = idx($map, $status); | $spec = idx($map, $status); | ||||
} | } | ||||
return (bool)idx($spec, 'isTracked', false); | return (bool)idx($spec, 'isTracked', false); | ||||
} | } | ||||
public function getDefaultBranch() { | public function getDefaultBranch() { | ||||
$default = $this->getDetail('default-branch'); | $default = $this->getDetail('default-branch'); | ||||
if (strlen($default)) { | if (phutil_nonempty_string($default)) { | ||||
return $default; | return $default; | ||||
} | } | ||||
$default_branches = array( | $default_branches = array( | ||||
PhabricatorRepositoryType::REPOSITORY_TYPE_GIT => 'master', | PhabricatorRepositoryType::REPOSITORY_TYPE_GIT => 'master', | ||||
PhabricatorRepositoryType::REPOSITORY_TYPE_MERCURIAL => 'default', | PhabricatorRepositoryType::REPOSITORY_TYPE_MERCURIAL => 'default', | ||||
); | ); | ||||
▲ Show 20 Lines • Show All 2,007 Lines • Show Last 20 Lines |