mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-26 16: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;
|
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) {
|
public function getHeraldField($field) {
|
||||||
$data = $this->commitData;
|
$data = $this->commitData;
|
||||||
switch ($field) {
|
switch ($field) {
|
||||||
|
@ -117,30 +136,24 @@ final class HeraldCommitAdapter extends HeraldObjectAdapter {
|
||||||
case HeraldFieldConfig::FIELD_REPOSITORY:
|
case HeraldFieldConfig::FIELD_REPOSITORY:
|
||||||
return $this->repository->getPHID();
|
return $this->repository->getPHID();
|
||||||
case HeraldFieldConfig::FIELD_DIFF_CONTENT:
|
case HeraldFieldConfig::FIELD_DIFF_CONTENT:
|
||||||
// TODO!
|
|
||||||
return null;
|
|
||||||
/*
|
|
||||||
try {
|
try {
|
||||||
$diff = $this->loadDiff();
|
$diff = $this->loadCommitDiff();
|
||||||
} catch (Exception $ex) {
|
} catch (Exception $ex) {
|
||||||
// See rE280053 for an example.
|
|
||||||
return array(
|
return array(
|
||||||
'<<< Failed to load diff, this usually means the change committed '.
|
'<<< Failed to load diff, this may mean the change was '.
|
||||||
'a binary file as text. >>>',
|
'unimaginably enormous. >>>');
|
||||||
);
|
|
||||||
}
|
}
|
||||||
$dict = array();
|
$dict = array();
|
||||||
$changes = $diff->getChangesets();
|
|
||||||
$lines = array();
|
$lines = array();
|
||||||
|
$changes = $diff->getChangesets();
|
||||||
foreach ($changes as $change) {
|
foreach ($changes as $change) {
|
||||||
$lines = array();
|
$lines = array();
|
||||||
foreach ($change->getHunks() as $hunk) {
|
foreach ($change->getHunks() as $hunk) {
|
||||||
$lines[] = $hunk->makeChanges();
|
$lines[] = $hunk->makeChanges();
|
||||||
}
|
}
|
||||||
$dict[$change->getTrueFilename()] = implode("\n", $lines);
|
$dict[$change->getFilename()] = implode("\n", $lines);
|
||||||
}
|
}
|
||||||
return $dict;
|
return $dict;
|
||||||
*/
|
|
||||||
case HeraldFieldConfig::FIELD_AFFECTED_PACKAGE:
|
case HeraldFieldConfig::FIELD_AFFECTED_PACKAGE:
|
||||||
$packages = $this->loadAffectedPackages();
|
$packages = $this->loadAffectedPackages();
|
||||||
return mpull($packages, 'getPHID');
|
return mpull($packages, 'getPHID');
|
||||||
|
|
Loading…
Reference in a new issue