Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F93859843
DiffusionRefsQueryConduitAPIMethod.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Mon, Dec 2, 02:00
Size
1 KB
Mime Type
text/x-php
Expires
Wed, Dec 4, 02:00 (1 d, 21 h)
Engine
blob
Format
Raw Data
Handle
22715612
Attached To
rPH Phabricator
DiffusionRefsQueryConduitAPIMethod.php
View Options
<?php
final
class
DiffusionRefsQueryConduitAPIMethod
extends
DiffusionQueryConduitAPIMethod
{
public
function
getAPIMethodName
()
{
return
'diffusion.refsquery'
;
}
public
function
getMethodDescription
()
{
return
pht
(
'Query a git repository for ref information at a specific commit.'
);
}
protected
function
defineReturnType
()
{
return
'array'
;
}
protected
function
defineCustomParamTypes
()
{
return
array
(
'commit'
=>
'required string'
,
);
}
protected
function
getGitResult
(
ConduitAPIRequest
$request
)
{
$drequest
=
$this
->
getDiffusionRequest
();
$repository
=
$drequest
->
getRepository
();
$commit
=
$request
->
getValue
(
'commit'
);
list
(
$stdout
)
=
$repository
->
execxLocalCommand
(
'log --format=%s -n 1 %s --'
,
'%d'
,
$commit
);
// %d, gives a weird output format
// similar to (remote/one, remote/two, remote/three)
$refs
=
trim
(
$stdout
,
"()
\n
"
);
if
(!
$refs
)
{
return
array
();
}
$refs
=
explode
(
','
,
$refs
);
$refs
=
array_map
(
'trim'
,
$refs
);
$ref_links
=
array
();
foreach
(
$refs
as
$ref
)
{
$ref_links
[]
=
array
(
'ref'
=>
$ref
,
'href'
=>
$drequest
->
generateURI
(
array
(
'action'
=>
'browse'
,
'branch'
=>
$ref
,
)),
);
}
return
$ref_links
;
}
}
Event Timeline
Log In to Comment