mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-28 09:42:41 +01:00
f0d16b3047
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
66 lines
1.8 KiB
PHP
66 lines
1.8 KiB
PHP
<?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());
|
|
}
|
|
|
|
}
|
|
|
|
}
|