@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 "author" information to conduit call

Summary: 'cuz we need it in arcanist for T479 to commit as author

Test Plan: verified the return value was correct in conduit

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Maniphest Tasks: T479

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

+61 -1
+11
conf/default.conf.php
··· 997 997 // interact with the revisions. 998 998 'differential.anonymous-access' => false, 999 999 1000 + // If you set this to true, revision author email address information will 1001 + // be exposed in Conduit. This is useful for Arcanist. 1002 + // 1003 + // For example, consider the "arc patch DX" workflow which needs to ask 1004 + // Differential for the revision DX. This data often should contain 1005 + // the author's email address, eg "George Washington 1006 + // <gwashinton@example.com>" when DX is a git or mercurial revision. If this 1007 + // option is false, Differential defaults to the best it can, something like 1008 + // "George Washington" or "gwashington". 1009 + 'differential.expose-emails-prudently' => false, 1010 + 1000 1011 // List of file regexps that should be treated as if they are generated by 1001 1012 // an automatic process, and thus get hidden by default in differential. 1002 1013 'differential.generated-paths' => array(
+2 -1
src/applications/conduit/method/differential/ConduitAPI_differential_getdiff_Method.php
··· 64 64 $basic_dict = $diff->getDiffDict(); 65 65 66 66 // for conduit calls, the basic dict is not enough 67 - // we also need to include the arcanist project 67 + // we also need to include the arcanist project and author information 68 68 $project = $diff->loadArcanistProject(); 69 69 if ($project) { 70 70 $project_name = $project->getName(); ··· 72 72 $project_name = null; 73 73 } 74 74 $basic_dict['projectName'] = $project_name; 75 + $basic_dict['author'] = $diff->loadAuthorInformation(); 75 76 76 77 return $basic_dict; 77 78 }
+48
src/applications/differential/storage/DifferentialDiff.php
··· 312 312 313 313 return $dict; 314 314 } 315 + 316 + /** 317 + * Figures out the right author information for a given diff based on the 318 + * repository and Phabricator configuration settings. 319 + * 320 + * Git is particularly finicky as it requires author information to be in 321 + * the format "George Washington <gwashington@example.com>" to 322 + * consistently work. If the Phabricator instance isn't configured to 323 + * expose emails prudently, then we are unable to get any author information 324 + * for git. 325 + */ 326 + public function loadAuthorInformation() { 327 + $author = id(new PhabricatorUser()) 328 + ->loadOneWhere('phid = %s', $this->getAuthorPHID()); 329 + 330 + $use_emails = 331 + PhabricatorEnv::getEnvConfig('differential.expose-emails-prudently', 332 + false); 333 + 334 + switch ($this->getSourceControlSystem()) { 335 + case PhabricatorRepositoryType::REPOSITORY_TYPE_GIT: 336 + if (!$use_emails) { 337 + $author_info = ''; 338 + } else { 339 + $author_info = $this->getFullAuthorInfo($author); 340 + } 341 + break; 342 + case PhabricatorRepositoryType::REPOSITORY_TYPE_MERCURIAL: 343 + if (!$use_emails) { 344 + $author_info = $author->getUsername(); 345 + } else { 346 + $author_info = $this->getFullAuthorInfo($author); 347 + } 348 + break; 349 + case PhabricatorRepositoryType::REPOSITORY_TYPE_SVN: 350 + default: 351 + $author_info = $author->getUsername(); 352 + break; 353 + } 354 + 355 + return $author_info; 356 + } 357 + 358 + private function getFullAuthorInfo(PhabricatorUser $author) { 359 + return sprintf('%s <%s>', 360 + $author->getRealName(), 361 + $author->loadPrimaryEmailAddress()); 362 + } 315 363 }