Changeset View
Changeset View
Standalone View
Standalone View
src/ref/ArcanistRepositoryRef.php
<?php | <?php | ||||
final class ArcanistRepositoryRef | final class ArcanistRepositoryRef | ||||
extends ArcanistRef { | extends ArcanistRef { | ||||
private $parameters = array(); | |||||
private $phid; | private $phid; | ||||
private $browseURI; | private $browseURI; | ||||
public function getRefDisplayName() { | public function getRefDisplayName() { | ||||
return pht('Remote Repository'); | return pht('Remote Repository'); | ||||
} | } | ||||
public function setPHID($phid) { | public function setPHID($phid) { | ||||
$this->phid = $phid; | $this->phid = $phid; | ||||
return $this; | return $this; | ||||
} | } | ||||
public function getPHID() { | public function getPHID() { | ||||
return $this->phid; | return $this->phid; | ||||
} | } | ||||
public function setBrowseURI($browse_uri) { | public function setBrowseURI($browse_uri) { | ||||
$this->browseURI = $browse_uri; | $this->browseURI = $browse_uri; | ||||
return $this; | return $this; | ||||
} | } | ||||
public static function newFromConduit(array $map) { | |||||
$ref = new self(); | |||||
$ref->parameters = $map; | |||||
$ref->phid = $map['phid']; | |||||
return $ref; | |||||
} | |||||
public function getURIs() { | |||||
$uris = idxv($this->parameters, array('attachments', 'uris', 'uris')); | |||||
if (!$uris) { | |||||
return array(); | |||||
} | |||||
$results = array(); | |||||
foreach ($uris as $uri) { | |||||
$effective_uri = idxv($uri, array('fields', 'uri', 'effective')); | |||||
if ($effective_uri !== null) { | |||||
$results[] = $effective_uri; | |||||
} | |||||
} | |||||
return $results; | |||||
} | |||||
public function getDisplayName() { | |||||
return idxv($this->parameters, array('fields', 'name')); | |||||
} | |||||
public function newBrowseURI(array $params) { | public function newBrowseURI(array $params) { | ||||
PhutilTypeSpec::checkMap( | PhutilTypeSpec::checkMap( | ||||
$params, | $params, | ||||
array( | array( | ||||
'path' => 'optional string|null', | 'path' => 'optional string|null', | ||||
'branch' => 'optional string|null', | 'branch' => 'optional string|null', | ||||
'lines' => 'optional string|null', | 'lines' => 'optional string|null', | ||||
)); | )); | ||||
Show All 27 Lines | public function newBrowseURI(array $params) { | ||||
// TODO: This construction, which includes a branch, is probably wrong for | // TODO: This construction, which includes a branch, is probably wrong for | ||||
// Subversion. | // Subversion. | ||||
return "{$uri_base}/browse/{$uri_branch}/{$uri_path}{$uri_lines}"; | return "{$uri_base}/browse/{$uri_branch}/{$uri_path}{$uri_lines}"; | ||||
} | } | ||||
public function getDefaultBranch() { | public function getDefaultBranch() { | ||||
// TODO: This should read from the remote, and is not correct for | $branch = idxv($this->parameters, array('fields', 'defaultBranch')); | ||||
// Mercurial anyway, as "default" would be a better default branch. | |||||
if ($branch === null) { | |||||
return 'master'; | return 'master'; | ||||
} | } | ||||
return $branch; | |||||
} | |||||
} | } |