Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F96941821
DifferentialCreateRawDiffConduitAPIMethod.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
Wed, Jan 1, 00:08
Size
1 KB
Mime Type
text/x-php
Expires
Fri, Jan 3, 00:08 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
23295913
Attached To
rPH Phabricator
DifferentialCreateRawDiffConduitAPIMethod.php
View Options
<?php
final
class
DifferentialCreateRawDiffConduitAPIMethod
extends
DifferentialConduitAPIMethod
{
public
function
getAPIMethodName
()
{
return
'differential.createrawdiff'
;
}
public
function
getMethodDescription
()
{
return
pht
(
'Create a new Differential diff from a raw diff source.'
);
}
public
function
defineParamTypes
()
{
return
array
(
'diff'
=>
'required string'
,
'repositoryPHID'
=>
'optional string'
,
);
}
public
function
defineReturnType
()
{
return
'nonempty dict'
;
}
public
function
defineErrorTypes
()
{
return
array
(
);
}
protected
function
execute
(
ConduitAPIRequest
$request
)
{
$viewer
=
$request
->
getUser
();
$raw_diff
=
$request
->
getValue
(
'diff'
);
$repository_phid
=
$request
->
getValue
(
'repositoryPHID'
);
if
(
$repository_phid
)
{
$repository
=
id
(
new
PhabricatorRepositoryQuery
())
->
setViewer
(
$viewer
)
->
withPHIDs
(
array
(
$repository_phid
))
->
executeOne
();
if
(!
$repository
)
{
throw
new
Exception
(
pht
(
'No such repository "%s"!'
,
$repository_phid
));
}
}
else
{
$repository
=
null
;
}
$parser
=
new
ArcanistDiffParser
();
$changes
=
$parser
->
parseDiff
(
$raw_diff
);
$diff
=
DifferentialDiff
::
newFromRawChanges
(
$changes
);
$diff
->
setLintStatus
(
DifferentialLintStatus
::
LINT_SKIP
);
$diff
->
setUnitStatus
(
DifferentialUnitStatus
::
UNIT_SKIP
);
$diff
->
setAuthorPHID
(
$viewer
->
getPHID
());
$diff
->
setCreationMethod
(
'web'
);
if
(
$repository
)
{
$diff
->
setRepositoryPHID
(
$repository
->
getPHID
());
}
$diff
->
save
();
return
$this
->
buildDiffInfoDictionary
(
$diff
);
}
}
Event Timeline
Log In to Comment