Correct Aphlict websocket URI construction after PHP8 compatibility changes
[phabricator.git] / src / applications / repository / customfield / PhabricatorCommitMergedCommitsField.php
blobc8a53b387da9c213d6b7c59e9ba8465bf21652ae
1 <?php
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() {
19 return true;
22 public function shouldAppearInTransactionMail() {
23 return true;
26 public function updateTransactionMailBody(
27 PhabricatorMetaMTAMailBody $body,
28 PhabricatorApplicationTransactionEditor $editor,
29 array $xactions) {
31 // Put all the merged commits info int the mail body if this is a merge
32 $merges_caption = '';
33 // TODO: Make this limit configurable after T6030
34 $limit = 50;
35 $commit = $this->getObject();
37 try {
38 $merges = DiffusionPathChange::newFromConduit(
39 id(new ConduitCall('diffusion.mergedcommitsquery', array(
40 'commit' => $commit->getCommitIdentifier(),
41 'limit' => $limit + 1,
42 'repository' => $commit->getRepository()->getPHID(),
43 )))
44 ->setUser($this->getViewer())
45 ->execute());
47 if (count($merges) > $limit) {
48 $merges = array_slice($merges, 0, $limit);
49 $merges_caption =
50 pht("This commit merges more than %d changes. Only the first ".
51 "%d are shown.\n", $limit, $limit);
54 if ($merges) {
55 $merge_commits = array();
56 foreach ($merges as $merge) {
57 $merge_commits[] = $merge->getAuthorName().
58 ': '.
59 $merge->getSummary();
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());