Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F97624677
ConduitAPI_diffusion_commitbranchesquery_Method.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
Sun, Jan 5, 20:15
Size
1 KB
Mime Type
text/x-php
Expires
Tue, Jan 7, 20:15 (2 d)
Engine
blob
Format
Raw Data
Handle
23369667
Attached To
rPH Phabricator
ConduitAPI_diffusion_commitbranchesquery_Method.php
View Options
<?php
/**
* @group conduit
*/
final
class
ConduitAPI_diffusion_commitbranchesquery_Method
extends
ConduitAPI_diffusion_abstractquery_Method
{
public
function
getMethodDescription
()
{
return
'Determine what branches contain a commit in a repository.'
;
}
public
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'
);
// NOTE: We can't use DiffusionLowLevelGitRefQuery here because
// `git for-each-ref` does not support `--contains`.
if
(
$repository
->
isWorkingCopyBare
())
{
list
(
$contains
)
=
$repository
->
execxLocalCommand
(
'branch --verbose --no-abbrev --contains %s'
,
$commit
);
return
DiffusionGitBranch
::
parseLocalBranchOutput
(
$contains
);
}
else
{
list
(
$contains
)
=
$repository
->
execxLocalCommand
(
'branch -r --verbose --no-abbrev --contains %s'
,
$commit
);
return
DiffusionGitBranch
::
parseRemoteBranchOutput
(
$contains
,
DiffusionBranchInformation
::
DEFAULT_GIT_REMOTE
);
}
}
protected
function
getMercurialResult
(
ConduitAPIRequest
$request
)
{
$drequest
=
$this
->
getDiffusionRequest
();
$repository
=
$drequest
->
getRepository
();
$commit
=
$request
->
getValue
(
'commit'
);
// TODO: This should use `branches`.
list
(
$contains
)
=
$repository
->
execxLocalCommand
(
'log --template %s --limit 1 --rev %s --'
,
'{branch}'
,
$commit
);
return
array
(
trim
(
$contains
)
=>
$commit
,
);
}
}
Event Timeline
Log In to Comment