Differential D20727 Diff 49419 src/applications/differential/conduit/DifferentialCreateDiffConduitAPIMethod.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/differential/conduit/DifferentialCreateDiffConduitAPIMethod.php
Show First 20 Lines • Show All 113 Lines • ▼ Show 20 Lines | switch ($request->getValue('unitStatus')) { | ||||
$unit_status = DifferentialUnitStatus::UNIT_FAIL; | $unit_status = DifferentialUnitStatus::UNIT_FAIL; | ||||
break; | break; | ||||
case 'none': | case 'none': | ||||
default: | default: | ||||
$unit_status = DifferentialUnitStatus::UNIT_NONE; | $unit_status = DifferentialUnitStatus::UNIT_NONE; | ||||
break; | break; | ||||
} | } | ||||
$source_path = $request->getValue('sourcePath'); | |||||
$source_path = $this->normalizeSourcePath($source_path); | |||||
$diff_data_dict = array( | $diff_data_dict = array( | ||||
'sourcePath' => $request->getValue('sourcePath'), | 'sourcePath' => $source_path, | ||||
'sourceMachine' => $request->getValue('sourceMachine'), | 'sourceMachine' => $request->getValue('sourceMachine'), | ||||
'branch' => $request->getValue('branch'), | 'branch' => $request->getValue('branch'), | ||||
'creationMethod' => $request->getValue('creationMethod'), | 'creationMethod' => $request->getValue('creationMethod'), | ||||
'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'), | ||||
Show All 21 Lines | protected function execute(ConduitAPIRequest $request) { | ||||
return array( | return array( | ||||
'diffid' => $diff->getID(), | 'diffid' => $diff->getID(), | ||||
'phid' => $diff->getPHID(), | 'phid' => $diff->getPHID(), | ||||
'uri' => $uri, | 'uri' => $uri, | ||||
); | ); | ||||
} | } | ||||
private function normalizeSourcePath($source_path) { | |||||
// See T13385. This property is probably headed for deletion. Until we get | |||||
// there, stop errors arising from running "arc diff" in a working copy | |||||
// with too many characters. | |||||
$max_size = id(new DifferentialDiff()) | |||||
->getColumnMaximumByteLength('sourcePath'); | |||||
return id(new PhutilUTF8StringTruncator()) | |||||
->setMaximumBytes($max_size) | |||||
->setTerminator('') | |||||
->truncateString($source_path); | |||||
} | |||||
} | } |