Page Menu
Home
Sealhub
Search
Configure Global Search
Log In
Files
F7859750
ArcanistRepositoryRef.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
ArcanistRepositoryRef.php
View Options
<?php
final
class
ArcanistRepositoryRef
extends
ArcanistRef
{
private
$phid
;
private
$browseURI
;
public
function
getRefIdentifier
()
{
return
pht
(
'Remote Repository'
);
}
public
function
defineHardpoints
()
{
return
array
();
}
public
function
setPHID
(
$phid
)
{
$this
->
phid
=
$phid
;
return
$this
;
}
public
function
getPHID
()
{
return
$this
->
phid
;
}
public
function
setBrowseURI
(
$browse_uri
)
{
$this
->
browseURI
=
$browse_uri
;
return
$this
;
}
public
function
newBrowseURI
(
array
$params
)
{
PhutilTypeSpec
::
checkMap
(
$params
,
array
(
'path'
=>
'optional string|null'
,
'branch'
=>
'optional string|null'
,
'lines'
=>
'optional string|null'
,
));
foreach
(
$params
as
$key
=>
$value
)
{
if
(!
strlen
(
$value
))
{
unset
(
$params
[
$key
]);
}
}
$defaults
=
array
(
'path'
=>
'/'
,
'branch'
=>
$this
->
getDefaultBranch
(),
'lines'
=>
null
,
);
$params
=
$params
+
$defaults
;
$uri_base
=
$this
->
browseURI
;
$uri_base
=
rtrim
(
$uri_base
,
'/'
);
$uri_branch
=
phutil_escape_uri_path_component
(
$params
[
'branch'
]);
$uri_path
=
ltrim
(
$params
[
'path'
],
'/'
);
$uri_path
=
phutil_escape_uri
(
$uri_path
);
$uri_lines
=
null
;
if
(
$params
[
'lines'
])
{
$uri_lines
=
'$'
.
phutil_escape_uri
(
$params
[
'lines'
]);
}
// TODO: This construction, which includes a branch, is probably wrong for
// Subversion.
return
"{$uri_base}/browse/{$uri_branch}/{$uri_path}{$uri_lines}"
;
}
public
function
getDefaultBranch
()
{
// TODO: This should read from the remote, and is not correct for
// Mercurial anyway, as "default" would be a better default branch.
return
'master'
;
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Wed, Aug 13, 17:01 (1 d, 7 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
867888
Default Alt Text
ArcanistRepositoryRef.php (1 KB)
Attached To
Mode
R118 Arcanist - fork
Attached
Detach File
Event Timeline
Log In to Comment