Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F101273929
ConduitAPI_diffusion_existsquery_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
Fri, Feb 7, 09:37
Size
1 KB
Mime Type
text/x-php
Expires
Sun, Feb 9, 09:37 (2 d)
Engine
blob
Format
Raw Data
Handle
24125585
Attached To
rPH Phabricator
ConduitAPI_diffusion_existsquery_Method.php
View Options
<?php
/**
* @group conduit
*/
final
class
ConduitAPI_diffusion_existsquery_Method
extends
ConduitAPI_diffusion_abstractquery_Method
{
public
function
getMethodDescription
()
{
return
'Determine if code exists in a version control system.'
;
}
public
function
defineReturnType
()
{
return
'bool'
;
}
protected
function
defineCustomParamTypes
()
{
return
array
(
'commit'
=>
'required string'
);
}
protected
function
getGitResult
(
ConduitAPIRequest
$request
)
{
$repository
=
$this
->
getDiffusionRequest
()->
getRepository
();
$commit
=
$request
->
getValue
(
'commit'
);
list
(
$err
,
$merge_base
)
=
$repository
->
execLocalCommand
(
'cat-file -t %s'
,
$commit
);
return
!
$err
;
}
protected
function
getSVNResult
(
ConduitAPIRequest
$request
)
{
$repository
=
$this
->
getDiffusionRequest
()->
getRepository
();
$commit
=
$request
->
getValue
(
'commit'
);
list
(
$info
)
=
$repository
->
execxRemoteCommand
(
'info %s'
,
$repository
->
getRemoteURI
());
$exists
=
false
;
$matches
=
null
;
if
(
preg_match
(
'/^Revision: (
\d
+)$/m'
,
$info
,
$matches
))
{
$base_revision
=
$matches
[
1
];
$exists
=
$base_revision
>=
$commit
;
}
return
$exists
;
}
protected
function
getMercurialResult
(
ConduitAPIRequest
$request
)
{
$repository
=
$this
->
getDiffusionRequest
()->
getRepository
();
$commit
=
$request
->
getValue
(
'commit'
);
list
(
$err
,
$stdout
)
=
$repository
->
execLocalCommand
(
'id --rev %s'
,
$commit
);
return
!
$err
;
}
}
Event Timeline
Log In to Comment