Differential D10542 Diff 25327 src/applications/repository/worker/PhabricatorRepositoryCommitHeraldWorker.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/repository/worker/PhabricatorRepositoryCommitHeraldWorker.php
| Show First 20 Lines • Show All 144 Lines • ▼ Show 20 Lines | private function applyHeraldRules( | ||||
| sort($files); | sort($files); | ||||
| if (count($files) > $limit) { | if (count($files) > $limit) { | ||||
| array_splice($files, $limit); | array_splice($files, $limit); | ||||
| $files[] = '(This commit affected more than '.$limit.' files. '. | $files[] = '(This commit affected more than '.$limit.' files. '. | ||||
| 'Only '.$limit.' are shown here and additional ones are truncated.)'; | 'Only '.$limit.' are shown here and additional ones are truncated.)'; | ||||
| } | } | ||||
| $files = implode("\n", $files); | $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(); | $xscript_id = $xscript->getID(); | ||||
| $why_uri = '/herald/transcript/'.$xscript_id.'/'; | $why_uri = '/herald/transcript/'.$xscript_id.'/'; | ||||
| $reply_handler = PhabricatorAuditCommentEditor::newReplyHandlerForCommit( | $reply_handler = PhabricatorAuditCommentEditor::newReplyHandlerForCommit( | ||||
| $commit); | $commit); | ||||
| $template = new PhabricatorMetaMTAMail(); | $template = new PhabricatorMetaMTAMail(); | ||||
| Show All 18 Lines | foreach ($field_list->getFields() as $field) { | ||||
| new DifferentialTransaction(), // Bogus object to satisfy typehint. | new DifferentialTransaction(), // Bogus object to satisfy typehint. | ||||
| $body); | $body); | ||||
| } catch (Exception $ex) { | } catch (Exception $ex) { | ||||
| // Log the exception and continue. | // Log the exception and continue. | ||||
| phlog($ex); | phlog($ex); | ||||
| } | } | ||||
| } | } | ||||
| // 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('DIFFERENTIAL REVISION'), $differential); | ||||
| $body->addTextSection(pht('AFFECTED FILES'), $files); | $body->addTextSection(pht('AFFECTED FILES'), $files); | ||||
| $body->addReplySection($reply_handler->getReplyHandlerInstructions()); | $body->addReplySection($reply_handler->getReplyHandlerInstructions()); | ||||
| $body->addHeraldSection($why_uri); | $body->addHeraldSection($why_uri); | ||||
| $body->addRawSection($inline_patch_text); | $body->addRawSection($inline_patch_text); | ||||
| $body = $body->render(); | $body = $body->render(); | ||||
| $prefix = PhabricatorEnv::getEnvConfig('metamta.diffusion.subject-prefix'); | $prefix = PhabricatorEnv::getEnvConfig('metamta.diffusion.subject-prefix'); | ||||
| ▲ Show 20 Lines • Show All 295 Lines • Show Last 20 Lines | |||||