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

When landing revisions via repository automation, use better metadata

Summary: Ref T182. Make a reasonable attempt to get the commit message, author, and committer data correct.

Test Plan: BEHOLD: rGITTEST810b7f17cd0c909256a45d29a5062fcf417d0489

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T182

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

+57 -4
+6
src/applications/differential/storage/DifferentialDiff.php
··· 251 251 252 252 $dict['changes'] = $this->buildChangesList(); 253 253 254 + return $dict + $this->getDiffAuthorshipDict(); 255 + } 256 + 257 + public function getDiffAuthorshipDict() { 258 + $dict = array(); 259 + 254 260 $properties = id(new DifferentialDiffProperty())->loadAllWhere( 255 261 'diffID = %d', 256 262 $this->getID());
+51 -4
src/applications/drydock/operation/DrydockLandRepositoryOperation.php
··· 48 48 $arg[] = $diff->getStagingRef(); 49 49 50 50 $merge_src = $diff->getStagingRef(); 51 + 52 + $dict = $diff->getDiffAuthorshipDict(); 53 + $author_name = idx($dict, 'authorName'); 54 + $author_email = idx($dict, 'authorEmail'); 55 + 56 + $api_method = 'differential.getcommitmessage'; 57 + $api_params = array( 58 + 'revision_id' => $revision->getID(), 59 + ); 60 + 61 + $commit_message = id(new ConduitCall($api_method, $api_params)) 62 + ->setUser($viewer) 63 + ->execute(); 51 64 } else { 52 65 throw new Exception( 53 66 pht( ··· 71 84 $target)); 72 85 } 73 86 87 + $committer_info = $this->getCommitterInfo($operation); 88 + 74 89 $cmd[] = 'git checkout %s'; 75 90 $arg[] = $merge_dst; 76 91 ··· 78 93 $arg[] = $merge_src; 79 94 80 95 $cmd[] = 'git -c user.name=%s -c user.email=%s commit --author %s -m %s'; 81 - $arg[] = 'autocommitter'; 82 - $arg[] = 'autocommitter@example.com'; 83 - $arg[] = 'autoauthor <autoauthor@example.com>'; 84 - $arg[] = pht('(Automerge!)'); 96 + 97 + $arg[] = $committer_info['name']; 98 + $arg[] = $committer_info['email']; 99 + 100 + $arg[] = "{$author_name} <{$author_email}>"; 101 + $arg[] = $commit_message; 85 102 86 103 $cmd[] = 'git push origin -- %s:%s'; 87 104 $arg[] = 'HEAD'; ··· 93 110 $result = call_user_func_array( 94 111 array($interface, 'execx'), 95 112 $argv); 113 + } 114 + 115 + private function getCommitterInfo(DrydockRepositoryOperation $operation) { 116 + $viewer = $this->getViewer(); 117 + 118 + $committer_name = null; 119 + 120 + $author_phid = $operation->getAuthorPHID(); 121 + $object = id(new PhabricatorObjectQuery()) 122 + ->setViewer($viewer) 123 + ->withPHIDs(array($author_phid)) 124 + ->executeOne(); 125 + 126 + if ($object) { 127 + if ($object instanceof PhabricatorUser) { 128 + $committer_name = $object->getUsername(); 129 + } 130 + } 131 + 132 + if (!strlen($committer_name)) { 133 + $committer_name = pht('autocommitter'); 134 + } 135 + 136 + // TODO: Probably let users choose a VCS email address in settings. For 137 + // now just make something up so we don't leak anyone's stuff. 138 + 139 + return array( 140 + 'name' => $committer_name, 141 + 'email' => 'autocommitter@example.com', 142 + ); 96 143 } 97 144 98 145 }