@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 a "tags" field to Diffusion commit

Summary:
- Fixes T4588.
- See D8501.
- Adds a "Tags" field for Herald commit emails.
- Fixes a bug in `tagsquery` when filtering by commit name.
- Make `tagsquery` just return nothing instead of fataling against Mercurial/Subversion.

Test Plan: Used `bin/repository/reparse.php --herald` to exercise this code.

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: aran, epriestley

Maniphest Tasks: T4588

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

+60 -7
+2
src/__phutil_library_map__.php
··· 1283 1283 'PhabricatorChatLogQuery' => 'applications/chatlog/PhabricatorChatLogQuery.php', 1284 1284 'PhabricatorCommitBranchesField' => 'applications/repository/customfield/PhabricatorCommitBranchesField.php', 1285 1285 'PhabricatorCommitCustomField' => 'applications/repository/customfield/PhabricatorCommitCustomField.php', 1286 + 'PhabricatorCommitTagsField' => 'applications/repository/customfield/PhabricatorCommitTagsField.php', 1286 1287 'PhabricatorCommonPasswords' => 'applications/auth/constants/PhabricatorCommonPasswords.php', 1287 1288 'PhabricatorConduitAPIController' => 'applications/conduit/controller/PhabricatorConduitAPIController.php', 1288 1289 'PhabricatorConduitCertificateToken' => 'applications/conduit/storage/PhabricatorConduitCertificateToken.php', ··· 3962 3963 'PhabricatorChatLogQuery' => 'PhabricatorCursorPagedPolicyAwareQuery', 3963 3964 'PhabricatorCommitBranchesField' => 'PhabricatorCommitCustomField', 3964 3965 'PhabricatorCommitCustomField' => 'PhabricatorCustomField', 3966 + 'PhabricatorCommitTagsField' => 'PhabricatorCommitCustomField', 3965 3967 'PhabricatorCommonPasswords' => 'Phobject', 3966 3968 'PhabricatorConduitAPIController' => 'PhabricatorConduitController', 3967 3969 'PhabricatorConduitCertificateToken' => 'PhabricatorConduitDAO',
+13 -4
src/applications/diffusion/conduit/ConduitAPI_diffusion_tagsquery_Method.php
··· 1 1 <?php 2 2 3 - /** 4 - * @group conduit 5 - */ 6 3 final class ConduitAPI_diffusion_tagsquery_Method 7 4 extends ConduitAPI_diffusion_abstractquery_Method { 8 5 ··· 38 35 39 36 $all_tags = $this->loadGitTagList(); 40 37 $all_tags = mpull($all_tags, null, 'getName'); 38 + 41 39 if ($name_filter !== null) { 42 40 $all_tags = array_intersect_key($all_tags, array_fuse($name_filter)); 43 41 } 44 42 if ($commit_filter !== null) { 45 - $all_tags = array_intersect_key($all_tags, array_fuse($commit_filter)); 43 + $all_tags = array_intersect_key($all_tags, $commit_filter); 46 44 } 45 + 47 46 $tags = array_values($all_tags); 48 47 49 48 $offset = $request->getValue('offset'); ··· 149 148 } 150 149 151 150 return $tags; 151 + } 152 + 153 + protected function getMercurialResult(ConduitAPIRequest $request) { 154 + // For now, we don't support Mercurial tags via API. 155 + return array(); 156 + } 157 + 158 + protected function getSVNResult(ConduitAPIRequest $request) { 159 + // Subversion has no meaningful concept of tags. 160 + return array(); 152 161 } 153 162 154 163 }
+37
src/applications/repository/customfield/PhabricatorCommitTagsField.php
··· 1 + <?php 2 + 3 + final class PhabricatorCommitTagsField 4 + extends PhabricatorCommitCustomField { 5 + 6 + public function getFieldKey() { 7 + return 'diffusion:tags'; 8 + } 9 + 10 + public function shouldAppearInApplicationTransactions() { 11 + return true; 12 + } 13 + 14 + public function buildApplicationTransactionMailBody( 15 + PhabricatorApplicationTransaction $xaction, 16 + PhabricatorMetaMTAMailBody $body) { 17 + 18 + $params = array( 19 + 'commit' => $this->getObject()->getCommitIdentifier(), 20 + 'callsign' => $this->getObject()->getRepository()->getCallsign(), 21 + ); 22 + 23 + $tags_raw = id(new ConduitCall('diffusion.tagsquery', $params)) 24 + ->setUser($this->getViewer()) 25 + ->execute(); 26 + 27 + $tags = DiffusionRepositoryTag::newFromConduit($tags_raw); 28 + if (!$tags) { 29 + return; 30 + } 31 + $tag_names = mpull($tags, 'getName'); 32 + sort($tag_names); 33 + 34 + $body->addTextSection(pht('TAGS'), implode(', ', $tag_names)); 35 + } 36 + 37 + }
+8 -3
src/applications/repository/worker/PhabricatorRepositoryCommitHeraldWorker.php
··· 167 167 ->setViewer(PhabricatorUser::getOmnipotentUser()) 168 168 ->readFieldsFromStorage($commit); 169 169 foreach ($field_list->getFields() as $field) { 170 - $field->buildApplicationTransactionMailBody( 171 - new DifferentialTransaction(), // Bogus object to satisfy typehint. 172 - $body); 170 + try { 171 + $field->buildApplicationTransactionMailBody( 172 + new DifferentialTransaction(), // Bogus object to satisfy typehint. 173 + $body); 174 + } catch (Exception $ex) { 175 + // Log the exception and continue. 176 + phlog($ex); 177 + } 173 178 } 174 179 175 180 $body->addTextSection(pht('DIFFERENTIAL REVISION'), $differential);