diff --git a/src/applications/repository/worker/PhabricatorRepositoryCommitHeraldWorker.php b/src/applications/repository/worker/PhabricatorRepositoryCommitHeraldWorker.php --- a/src/applications/repository/worker/PhabricatorRepositoryCommitHeraldWorker.php +++ b/src/applications/repository/worker/PhabricatorRepositoryCommitHeraldWorker.php @@ -150,6 +150,46 @@ } $files = implode("\n", $files); + // Get all the merged commits if this one is a merge + $merges = array(); + $merges_caption = ''; + $limit = 50; + try { + $drequest = DiffusionRequest::newFromDictionary( + array( + 'user' => PhabricatorUser::getOmnipotentUser(), + 'initFromConduit' => false, + 'repository' => $repository, + 'commit' => $commit->getCommitIdentifier(), + )); + + $merges = DiffusionQuery::callConduitWithDiffusionRequest( + PhabricatorUser::getOmnipotentUser(), + $drequest, + 'diffusion.mergedcommitsquery', + array( + 'commit' => $commit->getCommitIdentifier(), + 'limit' => $limit + 1)); + + if (count($merges)) { + for ($i = 0; $i < count($merges); $i++) { + $merges[$i] = $merges[$i]->getAuthorName(). + ': '. + $merges[$i]->getSummary(); + } + } + + 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"; + } + } catch (ConduitException $ex) { + // Log the exception and continue. + phlog($ex); + } + $xscript_id = $xscript->getID(); $why_uri = '/herald/transcript/'.$xscript_id.'/'; @@ -184,6 +224,18 @@ } } + // Add author into the body if we cannot us it in From: + $send_as_user = PhabricatorEnv::getEnvConfig('metamta.can-send-as-user'); + if (!$send_as_user || !$author_phid) { + $body->addTextSection(pht('AUTHOR'), $author_name); + } + + if (count($merges)) { + $body->addTextSection( + pht('MERGED COMMITS'), + $merges_caption.implode("\n", $merges)); + } + $body->addTextSection(pht('DIFFERENTIAL REVISION'), $differential); $body->addTextSection(pht('AFFECTED FILES'), $files); $body->addReplySection($reply_handler->getReplyHandlerInstructions());