Changeset View
Changeset View
Standalone View
Standalone View
src/applications/repository/storage/PhabricatorRepository.php
Show First 20 Lines • Show All 339 Lines • ▼ Show 20 Lines | final class PhabricatorRepository extends PhabricatorRepositoryDAO | ||||
* | * | ||||
* @return string | * @return string | ||||
*/ | */ | ||||
public function getCloneName() { | public function getCloneName() { | ||||
$name = $this->getRepositorySlug(); | $name = $this->getRepositorySlug(); | ||||
// Make some reasonable effort to produce reasonable default directory | // Make some reasonable effort to produce reasonable default directory | ||||
// names from repository names. | // names from repository names. | ||||
if (!strlen($name)) { | if ($name === null || !strlen($name)) { | ||||
$name = $this->getName(); | $name = $this->getName(); | ||||
$name = phutil_utf8_strtolower($name); | $name = phutil_utf8_strtolower($name); | ||||
$name = preg_replace('@[ -/:->]+@', '-', $name); | $name = preg_replace('@[ -/:->]+@', '-', $name); | ||||
$name = trim($name, '-'); | $name = trim($name, '-'); | ||||
if (!strlen($name)) { | if (!strlen($name)) { | ||||
$name = $this->getCallsign(); | $name = $this->getCallsign(); | ||||
} | } | ||||
} | } | ||||
▲ Show 20 Lines • Show All 359 Lines • ▼ Show 20 Lines | public function generateURI(array $params) { | ||||
$path = idx($params, 'path'); | $path = idx($params, 'path'); | ||||
$branch = idx($params, 'branch'); | $branch = idx($params, 'branch'); | ||||
$commit = idx($params, 'commit'); | $commit = idx($params, 'commit'); | ||||
$line = idx($params, 'line'); | $line = idx($params, 'line'); | ||||
$head = idx($params, 'head'); | $head = idx($params, 'head'); | ||||
$against = idx($params, 'against'); | $against = idx($params, 'against'); | ||||
if ($req_commit && !strlen($commit)) { | if ($req_commit && ($commit === null || !strlen($commit))) { | ||||
throw new Exception( | throw new Exception( | ||||
pht( | pht( | ||||
'Diffusion URI action "%s" requires commit!', | 'Diffusion URI action "%s" requires commit!', | ||||
$action)); | $action)); | ||||
} | } | ||||
if ($req_branch && !strlen($branch)) { | if ($req_branch && ($branch === null || !strlen($branch))) { | ||||
throw new Exception( | throw new Exception( | ||||
pht( | pht( | ||||
'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); | ||||
Show All 34 Lines | switch ($action) { | ||||
case 'branches': | case 'branches': | ||||
case 'lint': | case 'lint': | ||||
case 'pathtree': | case 'pathtree': | ||||
case 'refs': | case 'refs': | ||||
$uri = $this->getPathURI("/{$action}/{$path}{$commit}{$line}"); | $uri = $this->getPathURI("/{$action}/{$path}{$commit}{$line}"); | ||||
break; | break; | ||||
case 'compare': | case 'compare': | ||||
$uri = $this->getPathURI("/{$action}/"); | $uri = $this->getPathURI("/{$action}/"); | ||||
if (strlen($head)) { | if ($head !== null && strlen($head)) { | ||||
$query['head'] = $head; | $query['head'] = $head; | ||||
} else if (strlen($raw_commit)) { | } else if ($raw_commit !== null && strlen($raw_commit)) { | ||||
$query['commit'] = $raw_commit; | $query['commit'] = $raw_commit; | ||||
} else if (strlen($raw_branch)) { | } else if ($raw_branch !== null && strlen($raw_branch)) { | ||||
$query['head'] = $raw_branch; | $query['head'] = $raw_branch; | ||||
} | } | ||||
if (strlen($against)) { | if ($against !== null && strlen($against)) { | ||||
$query['against'] = $against; | $query['against'] = $against; | ||||
} | } | ||||
break; | break; | ||||
case 'branch': | case 'branch': | ||||
if (strlen($path)) { | if ($path != null && strlen($path)) { | ||||
$uri = $this->getPathURI("/repository/{$path}"); | $uri = $this->getPathURI("/repository/{$path}"); | ||||
} else { | } else { | ||||
$uri = $this->getPathURI('/'); | $uri = $this->getPathURI('/'); | ||||
} | } | ||||
break; | break; | ||||
case 'external': | case 'external': | ||||
$commit = ltrim($commit, ';'); | $commit = ltrim($commit, ';'); | ||||
$uri = "/diffusion/external/{$commit}/"; | $uri = "/diffusion/external/{$commit}/"; | ||||
▲ Show 20 Lines • Show All 351 Lines • ▼ Show 20 Lines | /* -( Repository URI Management )------------------------------------------ */ | ||||
/** | /** | ||||
* Get a parsed object representation of the repository's remote URI.. | * Get a parsed object representation of the repository's remote URI.. | ||||
* | * | ||||
* @return wild A @{class@arcanist:PhutilURI}. | * @return wild A @{class@arcanist:PhutilURI}. | ||||
* @task uri | * @task uri | ||||
*/ | */ | ||||
public function getRemoteURIObject() { | public function getRemoteURIObject() { | ||||
$raw_uri = $this->getDetail('remote-uri'); | $raw_uri = $this->getDetail('remote-uri'); | ||||
if (!strlen($raw_uri)) { | if ($raw_uri === null || !strlen($raw_uri)) { | ||||
return new PhutilURI(''); | return new PhutilURI(''); | ||||
} | } | ||||
if (!strncmp($raw_uri, '/', 1)) { | if (!strncmp($raw_uri, '/', 1)) { | ||||
return new PhutilURI('file://'.$raw_uri); | return new PhutilURI('file://'.$raw_uri); | ||||
} | } | ||||
return new PhutilURI($raw_uri); | return new PhutilURI($raw_uri); | ||||
▲ Show 20 Lines • Show All 1,641 Lines • ▼ Show 20 Lines | public function getFieldValuesForConduit() { | ||||
$track_rules = $this->getTrackOnlyRules(); | $track_rules = $this->getTrackOnlyRules(); | ||||
$permanent_rules = $this->getPermanentRefRules(); | $permanent_rules = $this->getPermanentRefRules(); | ||||
$fetch_rules = $this->getStringListForConduit($fetch_rules); | $fetch_rules = $this->getStringListForConduit($fetch_rules); | ||||
$track_rules = $this->getStringListForConduit($track_rules); | $track_rules = $this->getStringListForConduit($track_rules); | ||||
$permanent_rules = $this->getStringListForConduit($permanent_rules); | $permanent_rules = $this->getStringListForConduit($permanent_rules); | ||||
$default_branch = $this->getDefaultBranch(); | $default_branch = $this->getDefaultBranch(); | ||||
if (!strlen($default_branch)) { | if ($default_branch === null || !strlen($default_branch)) { | ||||
$default_branch = null; | $default_branch = null; | ||||
} | } | ||||
return array( | return array( | ||||
'name' => $this->getName(), | 'name' => $this->getName(), | ||||
'vcs' => $this->getVersionControlSystem(), | 'vcs' => $this->getVersionControlSystem(), | ||||
'callsign' => $this->getCallsign(), | 'callsign' => $this->getCallsign(), | ||||
'shortName' => $this->getRepositorySlug(), | 'shortName' => $this->getRepositorySlug(), | ||||
▲ Show 20 Lines • Show All 55 Lines • Show Last 20 Lines |