diff --git a/src/applications/audit/editor/PhabricatorAuditEditor.php b/src/applications/audit/editor/PhabricatorAuditEditor.php --- a/src/applications/audit/editor/PhabricatorAuditEditor.php +++ b/src/applications/audit/editor/PhabricatorAuditEditor.php @@ -619,6 +619,7 @@ if ($is_commit) { $data = $object->getCommitData(); + $this->showMergedCommits($body, $object); $body->addTextSection(pht('AFFECTED FILES'), $this->affectedFiles); $this->inlinePatch( $body, @@ -685,6 +686,53 @@ return $body; } + private function showMergedCommits( + PhabricatorMetaMTAMailBody $body, + PhabricatorRepositoryCommit $commit) { + + // Get all the merged commits if this one is a merge + $merges_caption = ''; + $limit = 50; + try { + $drequest = DiffusionRequest::newFromDictionary( + array( + 'user' => PhabricatorUser::getOmnipotentUser(), + 'initFromConduit' => false, + 'repository' => $commit->getRepository(), + 'commit' => $commit->getCommitIdentifier(), + )); + + $merges = DiffusionQuery::callConduitWithDiffusionRequest( + PhabricatorUser::getOmnipotentUser(), + $drequest, + 'diffusion.mergedcommitsquery', + array( + 'commit' => $commit->getCommitIdentifier(), + 'limit' => $limit + 1,)); + + if (count($merges) > $limit) { + $merges = array_slice($merges, 0, $limit); + $merges_caption = + "This commit merges more than {$limit} changes. Only the first ". + "{$limit} are shown.\n"; + } + + if ($merges) { + for ($i = 0; $i < count($merges); $i++) { + $merges[$i] = $merges[$i]->getAuthorName(). + ': '. + $merges[$i]->getSummary(); + } + $body->addTextSection( + pht('MERGED COMMITS'), + $merges_caption.implode("\n", $merges)); + } + } catch (ConduitException $ex) { + // Log the exception and continue. + phlog($ex); + } + } + private function attachPatch( PhabricatorMetaMTAMail $template, PhabricatorRepositoryCommit $commit) {