Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F96209636
PhabricatorDifferentialExtractWorkflow.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 23, 19:27
Size
1 KB
Mime Type
text/x-php
Expires
Wed, Dec 25, 19:27 (2 d)
Engine
blob
Format
Raw Data
Handle
23144150
Attached To
rPH Phabricator
PhabricatorDifferentialExtractWorkflow.php
View Options
<?php
final
class
PhabricatorDifferentialExtractWorkflow
extends
PhabricatorDifferentialManagementWorkflow
{
protected
function
didConstruct
()
{
$this
->
setName
(
'extract'
)
->
setExamples
(
'**extract** __commit__'
)
->
setSynopsis
(
pht
(
'Extract a diff from a commit.'
))
->
setArguments
(
array
(
array
(
'name'
=>
'extract'
,
'wildcard'
=>
true
,
'help'
=>
pht
(
'Commit to extract.'
),
),
));
}
public
function
execute
(
PhutilArgumentParser
$args
)
{
$viewer
=
$this
->
getViewer
();
$extract
=
$args
->
getArg
(
'extract'
);
if
(!
$extract
)
{
throw
new
PhutilArgumentUsageException
(
pht
(
'Specify a commit to extract the diff from.'
));
}
if
(
count
(
$extract
)
>
1
)
{
throw
new
PhutilArgumentUsageException
(
pht
(
'Specify exactly one commit to extract.'
));
}
$extract
=
head
(
$extract
);
$commit
=
id
(
new
DiffusionCommitQuery
())
->
setViewer
(
$viewer
)
->
withIdentifiers
(
array
(
$extract
))
->
executeOne
();
if
(!
$commit
)
{
throw
new
PhutilArgumentUsageException
(
pht
(
'Commit "%s" is not valid.'
,
$extract
));
}
$diff
=
id
(
new
DifferentialDiffExtractionEngine
())
->
setViewer
(
$viewer
)
->
newDiffFromCommit
(
$commit
);
$uri
=
PhabricatorEnv
::
getProductionURI
(
$diff
->
getURI
());
echo
tsprintf
(
"%s
\n\n
%s
\n
"
,
pht
(
'Extracted diff from "%s":'
,
$extract
),
$uri
);
}
}
Event Timeline
Log In to Comment