Differential D12894 Diff 31029 src/applications/differential/conduit/DifferentialCreateDiffConduitAPIMethod.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/differential/conduit/DifferentialCreateDiffConduitAPIMethod.php
<?php | <?php | ||||
final class DifferentialCreateDiffConduitAPIMethod | final class DifferentialCreateDiffConduitAPIMethod | ||||
extends DifferentialConduitAPIMethod { | extends DifferentialConduitAPIMethod { | ||||
public function getAPIMethodName() { | public function getAPIMethodName() { | ||||
return 'differential.creatediff'; | return 'differential.creatediff'; | ||||
} | } | ||||
public function getMethodDescription() { | public function getMethodDescription() { | ||||
return 'Create a new Differential diff.'; | return 'Create a new Differential diff.'; | ||||
} | } | ||||
protected function defineParamTypes() { | protected function defineParamTypes() { | ||||
$vcs_const = $this->formatStringConstants( | $vcs_const = $this->formatStringConstants( | ||||
array( | array( | ||||
'svn', | 'svn', | ||||
'git', | 'git', | ||||
'hg', | 'hg', | ||||
)); | )); | ||||
$status_const = $this->formatStringConstants( | $status_const = $this->formatStringConstants( | ||||
Show All 11 Lines | return array( | ||||
'sourceMachine' => 'required string', | 'sourceMachine' => 'required string', | ||||
'sourcePath' => 'required string', | 'sourcePath' => 'required string', | ||||
'branch' => 'required string', | 'branch' => 'required string', | ||||
'bookmark' => 'optional string', | 'bookmark' => 'optional string', | ||||
'sourceControlSystem' => 'required '.$vcs_const, | 'sourceControlSystem' => 'required '.$vcs_const, | ||||
'sourceControlPath' => 'required string', | 'sourceControlPath' => 'required string', | ||||
'sourceControlBaseRevision' => 'required string', | 'sourceControlBaseRevision' => 'required string', | ||||
'creationMethod' => 'optional string', | 'creationMethod' => 'optional string', | ||||
'arcanistProject' => 'optional string', | 'arcanistProject' => 'deprecated', | ||||
'lintStatus' => 'required '.$status_const, | 'lintStatus' => 'required '.$status_const, | ||||
'unitStatus' => 'required '.$status_const, | 'unitStatus' => 'required '.$status_const, | ||||
'repositoryPHID' => 'optional phid', | 'repositoryPHID' => 'optional phid', | ||||
'parentRevisionID' => 'deprecated', | 'parentRevisionID' => 'deprecated', | ||||
'authorPHID' => 'deprecated', | 'authorPHID' => 'deprecated', | ||||
'repositoryUUID' => 'deprecated', | 'repositoryUUID' => 'deprecated', | ||||
); | ); | ||||
Show All 27 Lines | if ($repository_phid) { | ||||
->withPHIDs(array($repository_phid)) | ->withPHIDs(array($repository_phid)) | ||||
->executeOne(); | ->executeOne(); | ||||
if ($repository) { | if ($repository) { | ||||
$repository_phid = $repository->getPHID(); | $repository_phid = $repository->getPHID(); | ||||
$repository_uuid = $repository->getUUID(); | $repository_uuid = $repository->getUUID(); | ||||
} | } | ||||
} | } | ||||
$project_name = $request->getValue('arcanistProject'); | |||||
$project_phid = null; | |||||
if ($project_name) { | |||||
$arcanist_project = id(new PhabricatorRepositoryArcanistProject()) | |||||
->loadOneWhere( | |||||
'name = %s', | |||||
$project_name); | |||||
if (!$arcanist_project) { | |||||
$arcanist_project = new PhabricatorRepositoryArcanistProject(); | |||||
$arcanist_project->setName($project_name); | |||||
$arcanist_project->save(); | |||||
} | |||||
$project_phid = $arcanist_project->getPHID(); | |||||
} | |||||
switch ($request->getValue('lintStatus')) { | switch ($request->getValue('lintStatus')) { | ||||
case 'skip': | case 'skip': | ||||
$lint_status = DifferentialLintStatus::LINT_SKIP; | $lint_status = DifferentialLintStatus::LINT_SKIP; | ||||
break; | break; | ||||
case 'okay': | case 'okay': | ||||
$lint_status = DifferentialLintStatus::LINT_OKAY; | $lint_status = DifferentialLintStatus::LINT_OKAY; | ||||
break; | break; | ||||
case 'warn': | case 'warn': | ||||
▲ Show 20 Lines • Show All 41 Lines • ▼ Show 20 Lines | $diff_data_dict = array( | ||||
'authorPHID' => $viewer->getPHID(), | 'authorPHID' => $viewer->getPHID(), | ||||
'bookmark' => $request->getValue('bookmark'), | 'bookmark' => $request->getValue('bookmark'), | ||||
'repositoryUUID' => $repository_uuid, | 'repositoryUUID' => $repository_uuid, | ||||
'repositoryPHID' => $repository_phid, | 'repositoryPHID' => $repository_phid, | ||||
'sourceControlSystem' => $request->getValue('sourceControlSystem'), | 'sourceControlSystem' => $request->getValue('sourceControlSystem'), | ||||
'sourceControlPath' => $request->getValue('sourceControlPath'), | 'sourceControlPath' => $request->getValue('sourceControlPath'), | ||||
'sourceControlBaseRevision' => | 'sourceControlBaseRevision' => | ||||
$request->getValue('sourceControlBaseRevision'), | $request->getValue('sourceControlBaseRevision'), | ||||
'arcanistProjectPHID' => $project_phid, | |||||
'lintStatus' => $lint_status, | 'lintStatus' => $lint_status, | ||||
'unitStatus' => $unit_status, | 'unitStatus' => $unit_status, | ||||
); | ); | ||||
$xactions = array(id(new DifferentialTransaction()) | $xactions = array(id(new DifferentialTransaction()) | ||||
->setTransactionType(DifferentialDiffTransaction::TYPE_DIFF_CREATE) | ->setTransactionType(DifferentialDiffTransaction::TYPE_DIFF_CREATE) | ||||
->setNewValue($diff_data_dict), | ->setNewValue($diff_data_dict), | ||||
); | ); | ||||
Show All 17 Lines |