mirror of
https://we.phorge.it/source/phorge.git
synced 2025-02-06 20:08:29 +01:00
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
This commit is contained in:
parent
1b12249b2c
commit
f0d16b3047
4 changed files with 91 additions and 3 deletions
|
@ -1541,6 +1541,7 @@ phutil_register_library_map(array(
|
||||||
'PhabricatorClusterConfigOptions' => 'applications/config/option/PhabricatorClusterConfigOptions.php',
|
'PhabricatorClusterConfigOptions' => 'applications/config/option/PhabricatorClusterConfigOptions.php',
|
||||||
'PhabricatorCommitBranchesField' => 'applications/repository/customfield/PhabricatorCommitBranchesField.php',
|
'PhabricatorCommitBranchesField' => 'applications/repository/customfield/PhabricatorCommitBranchesField.php',
|
||||||
'PhabricatorCommitCustomField' => 'applications/repository/customfield/PhabricatorCommitCustomField.php',
|
'PhabricatorCommitCustomField' => 'applications/repository/customfield/PhabricatorCommitCustomField.php',
|
||||||
|
'PhabricatorCommitMergedCommitsField' => 'applications/repository/customfield/PhabricatorCommitMergedCommitsField.php',
|
||||||
'PhabricatorCommitSearchEngine' => 'applications/audit/query/PhabricatorCommitSearchEngine.php',
|
'PhabricatorCommitSearchEngine' => 'applications/audit/query/PhabricatorCommitSearchEngine.php',
|
||||||
'PhabricatorCommitTagsField' => 'applications/repository/customfield/PhabricatorCommitTagsField.php',
|
'PhabricatorCommitTagsField' => 'applications/repository/customfield/PhabricatorCommitTagsField.php',
|
||||||
'PhabricatorCommonPasswords' => 'applications/auth/constants/PhabricatorCommonPasswords.php',
|
'PhabricatorCommonPasswords' => 'applications/auth/constants/PhabricatorCommonPasswords.php',
|
||||||
|
@ -4906,6 +4907,7 @@ phutil_register_library_map(array(
|
||||||
'PhabricatorClusterConfigOptions' => 'PhabricatorApplicationConfigOptions',
|
'PhabricatorClusterConfigOptions' => 'PhabricatorApplicationConfigOptions',
|
||||||
'PhabricatorCommitBranchesField' => 'PhabricatorCommitCustomField',
|
'PhabricatorCommitBranchesField' => 'PhabricatorCommitCustomField',
|
||||||
'PhabricatorCommitCustomField' => 'PhabricatorCustomField',
|
'PhabricatorCommitCustomField' => 'PhabricatorCustomField',
|
||||||
|
'PhabricatorCommitMergedCommitsField' => 'PhabricatorCommitCustomField',
|
||||||
'PhabricatorCommitSearchEngine' => 'PhabricatorApplicationSearchEngine',
|
'PhabricatorCommitSearchEngine' => 'PhabricatorApplicationSearchEngine',
|
||||||
'PhabricatorCommitTagsField' => 'PhabricatorCommitCustomField',
|
'PhabricatorCommitTagsField' => 'PhabricatorCommitCustomField',
|
||||||
'PhabricatorCommonPasswords' => 'Phobject',
|
'PhabricatorCommonPasswords' => 'Phobject',
|
||||||
|
|
|
@ -20,6 +20,21 @@ final class PhabricatorDiffusionConfigOptions
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getOptions() {
|
public function getOptions() {
|
||||||
|
$custom_field_type = 'custom:PhabricatorCustomFieldConfigOptionType';
|
||||||
|
|
||||||
|
$fields = array(
|
||||||
|
new PhabricatorCommitBranchesField(),
|
||||||
|
new PhabricatorCommitTagsField(),
|
||||||
|
new PhabricatorCommitMergedCommitsField(),
|
||||||
|
);
|
||||||
|
|
||||||
|
$default_fields = array();
|
||||||
|
foreach ($fields as $field) {
|
||||||
|
$default_fields[$field->getFieldKey()] = array(
|
||||||
|
'disabled' => $field->shouldDisableByDefault(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
return array(
|
return array(
|
||||||
$this->newOption(
|
$this->newOption(
|
||||||
'metamta.diffusion.subject-prefix',
|
'metamta.diffusion.subject-prefix',
|
||||||
|
@ -124,6 +139,13 @@ final class PhabricatorDiffusionConfigOptions
|
||||||
'from web traffic (for example, if you use different SSH and '.
|
'from web traffic (for example, if you use different SSH and '.
|
||||||
'web load balancers), you can set the SSH hostname here. This '.
|
'web load balancers), you can set the SSH hostname here. This '.
|
||||||
'is an advanced option.')),
|
'is an advanced option.')),
|
||||||
|
$this->newOption('diffusion.fields', $custom_field_type, $default_fields)
|
||||||
|
->setCustomData(
|
||||||
|
id(new PhabricatorRepositoryCommit())
|
||||||
|
->getCustomFieldBaseClass())
|
||||||
|
->setDescription(pht(
|
||||||
|
"Select and reorder diffusion fields.\n\n".
|
||||||
|
"These will primarily show up in Mail Notifications.")),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,66 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
final class PhabricatorCommitMergedCommitsField
|
||||||
|
extends PhabricatorCommitCustomField {
|
||||||
|
|
||||||
|
public function getFieldKey() {
|
||||||
|
return 'diffusion:mergedcommits';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function shouldDisableByDefault() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function shouldAppearInTransactionMail() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function updateTransactionMailBody(
|
||||||
|
PhabricatorMetaMTAMailBody $body,
|
||||||
|
PhabricatorApplicationTransactionEditor $editor,
|
||||||
|
array $xactions) {
|
||||||
|
|
||||||
|
// Put all the merged commits info int the mail body if this is a merge
|
||||||
|
$merges_caption = '';
|
||||||
|
// TODO: Make this limit configurable after T6030
|
||||||
|
$limit = 50;
|
||||||
|
$commit = $this->getObject();
|
||||||
|
|
||||||
|
try {
|
||||||
|
$merges = DiffusionPathChange::newFromConduit(
|
||||||
|
id(new ConduitCall('diffusion.mergedcommitsquery', array(
|
||||||
|
'commit' => $commit->getCommitIdentifier(),
|
||||||
|
'limit' => $limit + 1,
|
||||||
|
'callsign' => $commit->getRepository()->getCallsign(),
|
||||||
|
)))
|
||||||
|
->setUser($this->getViewer())
|
||||||
|
->execute());
|
||||||
|
|
||||||
|
if (count($merges) > $limit) {
|
||||||
|
$merges = array_slice($merges, 0, $limit);
|
||||||
|
$merges_caption =
|
||||||
|
pht("This commit merges more than %d changes. Only the first ".
|
||||||
|
"%d are shown.\n", $limit, $limit);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($merges) {
|
||||||
|
$merge_commits = array();
|
||||||
|
foreach ($merges as $merge) {
|
||||||
|
$merge_commits[] = $merge->getAuthorName().
|
||||||
|
': '.
|
||||||
|
$merge->getSummary();
|
||||||
|
}
|
||||||
|
$body->addTextSection(
|
||||||
|
pht('MERGED COMMITS'),
|
||||||
|
$merges_caption.implode("\n", $merge_commits));
|
||||||
|
}
|
||||||
|
} catch (ConduitException $ex) {
|
||||||
|
// Log the exception into the email body
|
||||||
|
$body->addTextSection(
|
||||||
|
pht('MERGED COMMITS'),
|
||||||
|
pht('Error generating merged commits: ').$ex->getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -349,9 +349,7 @@ final class PhabricatorRepositoryCommit
|
||||||
|
|
||||||
|
|
||||||
public function getCustomFieldSpecificationForRole($role) {
|
public function getCustomFieldSpecificationForRole($role) {
|
||||||
// TODO: We could make this configurable eventually, but just use the
|
return PhabricatorEnv::getEnvConfig('diffusion.fields');
|
||||||
// defaults for now.
|
|
||||||
return array();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getCustomFieldBaseClass() {
|
public function getCustomFieldBaseClass() {
|
||||||
|
|
Loading…
Add table
Reference in a new issue