mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-22 14:52:41 +01:00
Fix Herald "any changed content" rule for commits
Summary: Fixes T1330. This has been broken with a TODO since we open sourced. :/ Test Plan: Used test console to verify this produced the correct field value for several commits. Reviewers: btrahan, chad, vrana Reviewed By: chad CC: aran Maniphest Tasks: T1330 Differential Revision: https://secure.phabricator.com/D4563
This commit is contained in:
parent
1f7e9bcadd
commit
be91064a1d
1 changed files with 24 additions and 11 deletions
|
@ -103,6 +103,25 @@ final class HeraldCommitAdapter extends HeraldObjectAdapter {
|
|||
return $this->affectedRevision;
|
||||
}
|
||||
|
||||
private function loadCommitDiff() {
|
||||
$drequest = DiffusionRequest::newFromDictionary(
|
||||
array(
|
||||
'repository' => $this->repository,
|
||||
'commit' => $this->commit->getCommitIdentifier(),
|
||||
));
|
||||
|
||||
$raw = DiffusionRawDiffQuery::newFromDiffusionRequest($drequest)
|
||||
->setTimeout(60 * 60 * 15)
|
||||
->setLinesOfContext(0)
|
||||
->loadRawDiff();
|
||||
|
||||
$parser = new ArcanistDiffParser();
|
||||
$changes = $parser->parseDiff($raw);
|
||||
|
||||
$diff = DifferentialDiff::newFromRawChanges($changes);
|
||||
return $diff;
|
||||
}
|
||||
|
||||
public function getHeraldField($field) {
|
||||
$data = $this->commitData;
|
||||
switch ($field) {
|
||||
|
@ -117,30 +136,24 @@ final class HeraldCommitAdapter extends HeraldObjectAdapter {
|
|||
case HeraldFieldConfig::FIELD_REPOSITORY:
|
||||
return $this->repository->getPHID();
|
||||
case HeraldFieldConfig::FIELD_DIFF_CONTENT:
|
||||
// TODO!
|
||||
return null;
|
||||
/*
|
||||
try {
|
||||
$diff = $this->loadDiff();
|
||||
$diff = $this->loadCommitDiff();
|
||||
} catch (Exception $ex) {
|
||||
// See rE280053 for an example.
|
||||
return array(
|
||||
'<<< Failed to load diff, this usually means the change committed '.
|
||||
'a binary file as text. >>>',
|
||||
);
|
||||
'<<< Failed to load diff, this may mean the change was '.
|
||||
'unimaginably enormous. >>>');
|
||||
}
|
||||
$dict = array();
|
||||
$changes = $diff->getChangesets();
|
||||
$lines = array();
|
||||
$changes = $diff->getChangesets();
|
||||
foreach ($changes as $change) {
|
||||
$lines = array();
|
||||
foreach ($change->getHunks() as $hunk) {
|
||||
$lines[] = $hunk->makeChanges();
|
||||
}
|
||||
$dict[$change->getTrueFilename()] = implode("\n", $lines);
|
||||
$dict[$change->getFilename()] = implode("\n", $lines);
|
||||
}
|
||||
return $dict;
|
||||
*/
|
||||
case HeraldFieldConfig::FIELD_AFFECTED_PACKAGE:
|
||||
$packages = $this->loadAffectedPackages();
|
||||
return mpull($packages, 'getPHID');
|
||||
|
|
Loading…
Reference in a new issue