@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.

Pass commit authorship information to Buildkite

Summary:
Fixes T12251. Ref T13189. See PHI610. The difficulty here is that we don't want to disclose Phabricator account information to Buildkite. We're comfortable disclosing information from `git`, etc.

- For commits, use the Identity to provide authorship information from Git.
- For revisions, use the local commit information on the Diff to provide the Git/Mercurial/etc author of the HEAD commit.

Test Plan:
- Built commits and revisions in Buildkite via Harbormaster.
- I can't actually figure out how to see author information on the Buildkite side, but the values look sane when dumped locally.

Reviewers: amckinley

Subscribers: PHID-OPKG-gm6ozazyms6q6i22gyam

Maniphest Tasks: T13189, T12251

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

+76
+24
src/applications/differential/harbormaster/DifferentialBuildableEngine.php
··· 54 54 $this->applyTransactions(array($xaction)); 55 55 } 56 56 57 + public function getAuthorIdentity() { 58 + $object = $this->getObject(); 59 + 60 + if ($object instanceof DifferentialRevision) { 61 + $object = $object->loadActiveDiff(); 62 + } 63 + 64 + $authorship = $object->getDiffAuthorshipDict(); 65 + if (!isset($authorship['authorName'])) { 66 + return null; 67 + } 68 + 69 + $name = $authorship['authorName']; 70 + $address = idx($authorship, 'authorEmail'); 71 + 72 + $full = id(new PhutilEmailAddress()) 73 + ->setDisplayName($name) 74 + ->setAddress($address); 75 + 76 + return id(new PhabricatorRepositoryIdentity()) 77 + ->setIdentityName((string)$full) 78 + ->makeEphemeral(); 79 + } 80 + 57 81 }
+6
src/applications/diffusion/harbormaster/DiffusionBuildableEngine.php
··· 34 34 $this->applyTransactions(array($xaction)); 35 35 } 36 36 37 + public function getAuthorIdentity() { 38 + return $this->getObject() 39 + ->loadIdentities($this->getViewer()) 40 + ->getAuthorIdentity(); 41 + } 42 + 37 43 }
+3
src/applications/harbormaster/engine/HarbormasterBuildableEngine.php
··· 101 101 $xactions); 102 102 } 103 103 104 + public function getAuthorIdentity() { 105 + return null; 106 + } 104 107 105 108 }
+14
src/applications/harbormaster/step/HarbormasterBuildkiteBuildStepImplementation.php
··· 117 117 ), 118 118 ); 119 119 120 + $engine = HarbormasterBuildableEngine::newForObject( 121 + $object, 122 + $viewer); 123 + 124 + $author_identity = $engine->getAuthorIdentity(); 125 + if ($author_identity) { 126 + $data_structure += array( 127 + 'author' => array( 128 + 'name' => $author_identity->getIdentityDisplayName(), 129 + 'email' => $author_identity->getIdentityEmailAddress(), 130 + ), 131 + ); 132 + } 133 + 120 134 $json_data = phutil_json_encode($data_structure); 121 135 122 136 $credential_phid = $this->getSetting('token');
+19
src/applications/repository/storage/PhabricatorRepositoryCommit.php
··· 200 200 201 201 $this->authorIdentity = $author; 202 202 $this->committerIdentity = $committer; 203 + 204 + return $this; 203 205 } 204 206 205 207 public function getAuthorIdentity() { ··· 483 485 } 484 486 485 487 return null; 488 + } 489 + 490 + public function loadIdentities(PhabricatorUser $viewer) { 491 + if ($this->authorIdentity !== self::ATTACHABLE) { 492 + return $this; 493 + } 494 + 495 + $commit = id(new DiffusionCommitQuery()) 496 + ->setViewer($viewer) 497 + ->withIDs(array($this->getID())) 498 + ->needIdentities(true) 499 + ->executeOne(); 500 + 501 + $author_identity = $commit->getAuthorIdentity(); 502 + $committer_identity = $commit->getCommitterIdentity(); 503 + 504 + return $this->attachIdentities($author_identity, $committer_identity); 486 505 } 487 506 488 507 public function hasCommitterIdentity() {
+10
src/applications/repository/storage/PhabricatorRepositoryIdentity.php
··· 65 65 $this->getIdentityNameEncoding()); 66 66 } 67 67 68 + public function getIdentityEmailAddress() { 69 + $address = new PhutilEmailAddress($this->getIdentityName()); 70 + return $address->getAddress(); 71 + } 72 + 73 + public function getIdentityDisplayName() { 74 + $address = new PhutilEmailAddress($this->getIdentityName()); 75 + return $address->getDisplayName(); 76 + } 77 + 68 78 public function getIdentityShortName() { 69 79 // TODO 70 80 return $this->getIdentityName();