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

show merged commits in herald emails for merge commits

Summary:
Includes a new Block in Herad emails which tells the user about which commits were merged in a merge commit
Otherwise the email would just say "Merge branch XYZ". Ref T8295

Test Plan: imported various commits (and merges) and watched resulting herald emails for all of them

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: Korvin, epriestley

Maniphest Tasks: T8295

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

authored by

Fabian Stelzer and committed by
epriestley
f0d16b30 1b12249b

+91 -3
+2
src/__phutil_library_map__.php
··· 1541 1541 'PhabricatorClusterConfigOptions' => 'applications/config/option/PhabricatorClusterConfigOptions.php', 1542 1542 'PhabricatorCommitBranchesField' => 'applications/repository/customfield/PhabricatorCommitBranchesField.php', 1543 1543 'PhabricatorCommitCustomField' => 'applications/repository/customfield/PhabricatorCommitCustomField.php', 1544 + 'PhabricatorCommitMergedCommitsField' => 'applications/repository/customfield/PhabricatorCommitMergedCommitsField.php', 1544 1545 'PhabricatorCommitSearchEngine' => 'applications/audit/query/PhabricatorCommitSearchEngine.php', 1545 1546 'PhabricatorCommitTagsField' => 'applications/repository/customfield/PhabricatorCommitTagsField.php', 1546 1547 'PhabricatorCommonPasswords' => 'applications/auth/constants/PhabricatorCommonPasswords.php', ··· 4906 4907 'PhabricatorClusterConfigOptions' => 'PhabricatorApplicationConfigOptions', 4907 4908 'PhabricatorCommitBranchesField' => 'PhabricatorCommitCustomField', 4908 4909 'PhabricatorCommitCustomField' => 'PhabricatorCustomField', 4910 + 'PhabricatorCommitMergedCommitsField' => 'PhabricatorCommitCustomField', 4909 4911 'PhabricatorCommitSearchEngine' => 'PhabricatorApplicationSearchEngine', 4910 4912 'PhabricatorCommitTagsField' => 'PhabricatorCommitCustomField', 4911 4913 'PhabricatorCommonPasswords' => 'Phobject',
+22
src/applications/diffusion/config/PhabricatorDiffusionConfigOptions.php
··· 20 20 } 21 21 22 22 public function getOptions() { 23 + $custom_field_type = 'custom:PhabricatorCustomFieldConfigOptionType'; 24 + 25 + $fields = array( 26 + new PhabricatorCommitBranchesField(), 27 + new PhabricatorCommitTagsField(), 28 + new PhabricatorCommitMergedCommitsField(), 29 + ); 30 + 31 + $default_fields = array(); 32 + foreach ($fields as $field) { 33 + $default_fields[$field->getFieldKey()] = array( 34 + 'disabled' => $field->shouldDisableByDefault(), 35 + ); 36 + } 37 + 23 38 return array( 24 39 $this->newOption( 25 40 'metamta.diffusion.subject-prefix', ··· 124 139 'from web traffic (for example, if you use different SSH and '. 125 140 'web load balancers), you can set the SSH hostname here. This '. 126 141 'is an advanced option.')), 142 + $this->newOption('diffusion.fields', $custom_field_type, $default_fields) 143 + ->setCustomData( 144 + id(new PhabricatorRepositoryCommit()) 145 + ->getCustomFieldBaseClass()) 146 + ->setDescription(pht( 147 + "Select and reorder diffusion fields.\n\n". 148 + "These will primarily show up in Mail Notifications.")), 127 149 ); 128 150 } 129 151
+66
src/applications/repository/customfield/PhabricatorCommitMergedCommitsField.php
··· 1 + <?php 2 + 3 + final class PhabricatorCommitMergedCommitsField 4 + extends PhabricatorCommitCustomField { 5 + 6 + public function getFieldKey() { 7 + return 'diffusion:mergedcommits'; 8 + } 9 + 10 + public function shouldDisableByDefault() { 11 + return true; 12 + } 13 + 14 + public function shouldAppearInTransactionMail() { 15 + return true; 16 + } 17 + 18 + public function updateTransactionMailBody( 19 + PhabricatorMetaMTAMailBody $body, 20 + PhabricatorApplicationTransactionEditor $editor, 21 + array $xactions) { 22 + 23 + // Put all the merged commits info int the mail body if this is a merge 24 + $merges_caption = ''; 25 + // TODO: Make this limit configurable after T6030 26 + $limit = 50; 27 + $commit = $this->getObject(); 28 + 29 + try { 30 + $merges = DiffusionPathChange::newFromConduit( 31 + id(new ConduitCall('diffusion.mergedcommitsquery', array( 32 + 'commit' => $commit->getCommitIdentifier(), 33 + 'limit' => $limit + 1, 34 + 'callsign' => $commit->getRepository()->getCallsign(), 35 + ))) 36 + ->setUser($this->getViewer()) 37 + ->execute()); 38 + 39 + if (count($merges) > $limit) { 40 + $merges = array_slice($merges, 0, $limit); 41 + $merges_caption = 42 + pht("This commit merges more than %d changes. Only the first ". 43 + "%d are shown.\n", $limit, $limit); 44 + } 45 + 46 + if ($merges) { 47 + $merge_commits = array(); 48 + foreach ($merges as $merge) { 49 + $merge_commits[] = $merge->getAuthorName(). 50 + ': '. 51 + $merge->getSummary(); 52 + } 53 + $body->addTextSection( 54 + pht('MERGED COMMITS'), 55 + $merges_caption.implode("\n", $merge_commits)); 56 + } 57 + } catch (ConduitException $ex) { 58 + // Log the exception into the email body 59 + $body->addTextSection( 60 + pht('MERGED COMMITS'), 61 + pht('Error generating merged commits: ').$ex->getMessage()); 62 + } 63 + 64 + } 65 + 66 + }
+1 -3
src/applications/repository/storage/PhabricatorRepositoryCommit.php
··· 349 349 350 350 351 351 public function getCustomFieldSpecificationForRole($role) { 352 - // TODO: We could make this configurable eventually, but just use the 353 - // defaults for now. 354 - return array(); 352 + return PhabricatorEnv::getEnvConfig('diffusion.fields'); 355 353 } 356 354 357 355 public function getCustomFieldBaseClass() {