2012-06-20 21:35:04 +02:00
|
|
|
<?php
|
|
|
|
|
Rename Conduit classes
Summary: Ref T5655. Rename Conduit classes and provide a `getAPIMethodName` method to declare the API method.
Test Plan:
```
> echo '{}' | arc --conduit-uri='http://phabricator.joshuaspence.com' call-conduit user.whoami
Waiting for JSON parameters on stdin...
{"error":null,"errorMessage":null,"response":{"phid":"PHID-USER-lioqffnwn6y475mu5ndb","userName":"josh","realName":"Joshua Spence","image":"http:\/\/phabricator.joshuaspence.com\/res\/1404425321T\/phabricator\/3eb28cd9\/rsrc\/image\/avatar.png","uri":"http:\/\/phabricator.joshuaspence.com\/p\/josh\/","roles":["admin","verified","approved","activated"]}}
```
Reviewers: epriestley, #blessed_reviewers
Reviewed By: epriestley, #blessed_reviewers
Subscribers: epriestley, Korvin, hach-que
Maniphest Tasks: T5655
Differential Revision: https://secure.phabricator.com/D9991
2014-07-25 02:54:15 +02:00
|
|
|
final class DifferentialCreateRawDiffConduitAPIMethod
|
|
|
|
extends DifferentialConduitAPIMethod {
|
|
|
|
|
|
|
|
public function getAPIMethodName() {
|
|
|
|
return 'differential.createrawdiff';
|
|
|
|
}
|
2012-06-20 21:35:04 +02:00
|
|
|
|
|
|
|
public function getMethodDescription() {
|
2014-06-09 20:36:49 +02:00
|
|
|
return pht('Create a new Differential diff from a raw diff source.');
|
2012-06-20 21:35:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public function defineParamTypes() {
|
|
|
|
return array(
|
|
|
|
'diff' => 'required string',
|
2014-05-10 03:06:41 +02:00
|
|
|
'repositoryPHID' => 'optional string',
|
2012-06-20 21:35:04 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function defineReturnType() {
|
|
|
|
return 'nonempty dict';
|
|
|
|
}
|
|
|
|
|
|
|
|
public function defineErrorTypes() {
|
|
|
|
return array(
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected function execute(ConduitAPIRequest $request) {
|
2014-05-10 03:06:41 +02:00
|
|
|
$viewer = $request->getUser();
|
2012-06-20 21:35:04 +02:00
|
|
|
$raw_diff = $request->getValue('diff');
|
|
|
|
|
2014-05-10 03:06:41 +02:00
|
|
|
$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;
|
|
|
|
}
|
|
|
|
|
2012-06-20 21:35:04 +02:00
|
|
|
$parser = new ArcanistDiffParser();
|
|
|
|
$changes = $parser->parseDiff($raw_diff);
|
|
|
|
$diff = DifferentialDiff::newFromRawChanges($changes);
|
|
|
|
|
|
|
|
$diff->setLintStatus(DifferentialLintStatus::LINT_SKIP);
|
2012-08-13 22:51:10 +02:00
|
|
|
$diff->setUnitStatus(DifferentialUnitStatus::UNIT_SKIP);
|
2012-06-20 21:35:04 +02:00
|
|
|
|
2014-05-10 03:06:41 +02:00
|
|
|
$diff->setAuthorPHID($viewer->getPHID());
|
2012-06-20 21:35:04 +02:00
|
|
|
$diff->setCreationMethod('web');
|
2014-05-10 03:06:41 +02:00
|
|
|
|
|
|
|
if ($repository) {
|
|
|
|
$diff->setRepositoryPHID($repository->getPHID());
|
|
|
|
}
|
|
|
|
|
2012-06-20 21:35:04 +02:00
|
|
|
$diff->save();
|
|
|
|
|
|
|
|
return $this->buildDiffInfoDictionary($diff);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|