Differential D12993 Diff 31342 src/applications/repository/customfield/PhabricatorCommitMergedCommitsField.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/repository/customfield/PhabricatorCommitMergedCommitsField.php
- This file was added.
<?php | |||||
final class PhabricatorCommitMergedCommitsField | |||||
extends PhabricatorCommitCustomField { | |||||
public function getFieldKey() { | |||||
return 'diffusion:mergedcommits'; | |||||
} | |||||
public function shouldDisableByDefault() { | |||||
return true; | |||||
} | |||||
public function shouldAppearInTransactionMail() { | |||||
return true; | |||||
} | |||||
public function updateTransactionMailBody( | |||||
PhabricatorMetaMTAMailBody $body, | |||||
PhabricatorApplicationTransactionEditor $editor, | |||||
array $xactions) { | |||||
// Put all the merged commits info int the mail body if this is a merge | |||||
$merges_caption = ''; | |||||
// TODO: Make this limit configurable after T6030 | |||||
$limit = 50; | |||||
$commit = $this->getObject(); | |||||
try { | |||||
$merges = DiffusionPathChange::newFromConduit( | |||||
id(new ConduitCall('diffusion.mergedcommitsquery', array( | |||||
'commit' => $commit->getCommitIdentifier(), | |||||
'limit' => $limit + 1, | |||||
epriestley: This should be the actual viewer -- I think `$this->getViewer()` will work. | |||||
'callsign' => $commit->getRepository()->getCallsign(), | |||||
Not Done Inline ActionsI think this is no longer used for anything and has no effect (we determine it automatically in all cases, now). epriestley: I think this is no longer used for anything and has no effect (we determine it automatically in… | |||||
))) | |||||
->setUser($this->getViewer()) | |||||
->execute()); | |||||
if (count($merges) > $limit) { | |||||
$merges = array_slice($merges, 0, $limit); | |||||
Not Done Inline ActionsUsing ConduitCall directly (as in PhabricatorCommitBranchesField) might be a little simpler than building a DiffusionRequest. epriestley: Using ConduitCall directly (as in `PhabricatorCommitBranchesField`) might be a little simpler… | |||||
$merges_caption = | |||||
Not Done Inline ActionsUse real viewer. epriestley: Use real viewer. | |||||
pht("This commit merges more than %d changes. Only the first ". | |||||
"%d are shown.\n", $limit, $limit); | |||||
} | |||||
if ($merges) { | |||||
$merge_commits = array(); | |||||
foreach ($merges as $merge) { | |||||
$merge_commits[] = $merge->getAuthorName(). | |||||
': '. | |||||
$merge->getSummary(); | |||||
} | |||||
$body->addTextSection( | |||||
Not Done Inline ActionsUse pht(). epriestley: Use `pht()`. | |||||
pht('MERGED COMMITS'), | |||||
$merges_caption.implode("\n", $merge_commits)); | |||||
} | |||||
} catch (ConduitException $ex) { | |||||
// Log the exception into the email body | |||||
$body->addTextSection( | |||||
pht('MERGED COMMITS'), | |||||
pht('Error generating merged commits: ').$ex->getMessage()); | |||||
Not Done Inline ActionsMaybe simpler with foreach ($merges as $merge). epriestley: Maybe simpler with `foreach ($merges as $merge)`. | |||||
} | |||||
} | |||||
} | |||||
Not Done Inline ActionsMaybe put $ex->getMessage() in the mail body? So we end up with something like:
That seems more obvious/helpful than just dumping it to the webserver error log. epriestley: Maybe put $ex->getMessage() in the mail body? So we end up with something like:
> MERGED… |
This should be the actual viewer -- I think $this->getViewer() will work.