Add a "differential.createrawdiff" Conduit method
Summary: "differential.creatediff" requires a mostly-parsed diff, but there's no reason we can't make DifferentialDiffs out of raw diffs. This mainly serves to lower the adoption barrier if getting "arc" distributed is too much of a hassle. Test Plan: Made a diff out of a raw block of diff text. Reviewers: ffx, vrana, btrahan Reviewed By: btrahan CC: aran Differential Revision: https://secure.phabricator.com/D2751
This commit is contained in:
@@ -23,25 +23,23 @@ final class DifferentialDiffCreateController extends DifferentialController {
|
||||
$request = $this->getRequest();
|
||||
|
||||
if ($request->isFormPost()) {
|
||||
$parser = new ArcanistDiffParser();
|
||||
$diff = null;
|
||||
try {
|
||||
$diff = PhabricatorFile::readUploadedFileData($_FILES['diff-file']);
|
||||
} catch (Exception $ex) {
|
||||
$diff = $request->getStr('diff');
|
||||
}
|
||||
$changes = $parser->parseDiff($diff);
|
||||
$diff = DifferentialDiff::newFromRawChanges($changes);
|
||||
|
||||
$diff->setLintStatus(DifferentialLintStatus::LINT_SKIP);
|
||||
$diff->setUnitStatus(DifferentialLintStatus::LINT_SKIP);
|
||||
$call = new ConduitCall(
|
||||
'differential.createrawdiff',
|
||||
array(
|
||||
'diff' => $diff,
|
||||
));
|
||||
$call->setUser($request->getUser());
|
||||
$result = $call->execute();
|
||||
|
||||
$diff->setAuthorPHID($request->getUser()->getPHID());
|
||||
$diff->setCreationMethod('web');
|
||||
$diff->save();
|
||||
|
||||
return id(new AphrontRedirectResponse())
|
||||
->setURI('/differential/diff/'.$diff->getID().'/');
|
||||
$path = id(new PhutilURI($result['uri']))->getPath();
|
||||
return id(new AphrontRedirectResponse())->setURI($path);
|
||||
}
|
||||
|
||||
$form = new AphrontFormView();
|
||||
|
||||
Reference in New Issue
Block a user