3 final class PhabricatorCommitMergedCommitsField
4 extends PhabricatorCommitCustomField
{
6 public function getFieldKey() {
7 return 'diffusion:mergedcommits';
10 public function getFieldName() {
11 return pht('Merged Commits');
14 public function getFieldDescription() {
15 return pht('For merge commits, shows merged changes in email.');
18 public function shouldDisableByDefault() {
22 public function shouldAppearInTransactionMail() {
26 public function updateTransactionMailBody(
27 PhabricatorMetaMTAMailBody
$body,
28 PhabricatorApplicationTransactionEditor
$editor,
31 // Put all the merged commits info int the mail body if this is a merge
33 // TODO: Make this limit configurable after T6030
35 $commit = $this->getObject();
38 $merges = DiffusionPathChange
::newFromConduit(
39 id(new ConduitCall('diffusion.mergedcommitsquery', array(
40 'commit' => $commit->getCommitIdentifier(),
41 'limit' => $limit +
1,
42 'repository' => $commit->getRepository()->getPHID(),
44 ->setUser($this->getViewer())
47 if (count($merges) > $limit) {
48 $merges = array_slice($merges, 0, $limit);
50 pht("This commit merges more than %d changes. Only the first ".
51 "%d are shown.\n", $limit, $limit);
55 $merge_commits = array();
56 foreach ($merges as $merge) {
57 $merge_commits[] = $merge->getAuthorName().
61 $body->addTextSection(
62 pht('MERGED COMMITS'),
63 $merges_caption.implode("\n", $merge_commits));
65 } catch (ConduitException
$ex) {
66 // Log the exception into the email body
67 $body->addTextSection(
68 pht('MERGED COMMITS'),
69 pht('Error generating merged commits: ').$ex->getMessage());