@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Add 'repositoryPHID' to 'differential.createrawdiff'

Summary:
See <https://github.com/facebook/phabricator/issues/596>

Broadly, Facebook would like to bring Pull Requests from GitHub into Phabricator.

In the long term we can do this properly via Doorkeeper/Nuance, but that's probably a ways off. This seems like a reasonable low-budget compromise for now.

I'm a little hesitant to add a ton of parameters to this call, but `repositoryPHID` seems pretty reasonable, and is notable because it also controls default policies.

Test Plan:
- Created a diff with no repositoryPHID.
- Created a diff with a repositoryPHID.
- Verified it carried over when the diff was used to create a revision.

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: ptarjan, jamesgpearce, epriestley

Differential Revision: https://secure.phabricator.com/D9023

+23 -2
+23 -2
src/applications/differential/conduit/ConduitAPI_differential_createrawdiff_Method.php
··· 4 4 extends ConduitAPI_differential_Method { 5 5 6 6 public function getMethodDescription() { 7 - return "Create a new Differential diff from a raw diff source."; 7 + return pht("Create a new Differential diff from a raw diff source."); 8 8 } 9 9 10 10 public function defineParamTypes() { 11 11 return array( 12 12 'diff' => 'required string', 13 + 'repositoryPHID' => 'optional string', 13 14 ); 14 15 } 15 16 ··· 23 24 } 24 25 25 26 protected function execute(ConduitAPIRequest $request) { 27 + $viewer = $request->getUser(); 26 28 $raw_diff = $request->getValue('diff'); 27 29 30 + $repository_phid = $request->getValue('repositoryPHID'); 31 + if ($repository_phid) { 32 + $repository = id(new PhabricatorRepositoryQuery()) 33 + ->setViewer($viewer) 34 + ->withPHIDs(array($repository_phid)) 35 + ->executeOne(); 36 + if (!$repository) { 37 + throw new Exception( 38 + pht('No such repository "%s"!', $repository_phid)); 39 + } 40 + } else { 41 + $repository = null; 42 + } 43 + 28 44 $parser = new ArcanistDiffParser(); 29 45 $changes = $parser->parseDiff($raw_diff); 30 46 $diff = DifferentialDiff::newFromRawChanges($changes); ··· 32 48 $diff->setLintStatus(DifferentialLintStatus::LINT_SKIP); 33 49 $diff->setUnitStatus(DifferentialUnitStatus::UNIT_SKIP); 34 50 35 - $diff->setAuthorPHID($request->getUser()->getPHID()); 51 + $diff->setAuthorPHID($viewer->getPHID()); 36 52 $diff->setCreationMethod('web'); 53 + 54 + if ($repository) { 55 + $diff->setRepositoryPHID($repository->getPHID()); 56 + } 57 + 37 58 $diff->save(); 38 59 39 60 return $this->buildDiffInfoDictionary($diff);