mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-19 05:12:41 +01:00
Allow DifferentialDiff to construct proper DifferentialChangeset objects from
diffs which add empty files Summary: See T507 and some others. We now parse empty git diffs correctly, but the logic to build DifferentialDiffs out of them leaves the objects with 'null' for $changesets, when it should be array(). Further layers later throw, believing we have not loaded the changesets, when we actually have, there just aren't any. Test Plan: Viewed rJX05d493e17fbbb29f29e4880be6834d1d7415374e in Diffusion, which adds an empty README file. No exception thrown. Reviewers: jungejason, nh, tuomaspelkonen, aran Reviewed By: nh CC: aran, nh Differential Revision: 1038
This commit is contained in:
parent
c84cfef16c
commit
88be49fd5f
1 changed files with 17 additions and 11 deletions
|
@ -114,17 +114,23 @@ class DifferentialDiff extends DifferentialDAO {
|
|||
$changeset = new DifferentialChangeset();
|
||||
$add_lines = 0;
|
||||
$del_lines = 0;
|
||||
foreach ($change->getHunks() as $hunk) {
|
||||
$dhunk = new DifferentialHunk();
|
||||
$dhunk->setOldOffset($hunk->getOldOffset());
|
||||
$dhunk->setOldLen($hunk->getOldLength());
|
||||
$dhunk->setNewOffset($hunk->getNewOffset());
|
||||
$dhunk->setNewLen($hunk->getNewLength());
|
||||
$dhunk->setChanges($hunk->getCorpus());
|
||||
$changeset->addUnsavedHunk($dhunk);
|
||||
$add_lines += $hunk->getAddLines();
|
||||
$del_lines += $hunk->getDelLines();
|
||||
$lines += $add_lines + $del_lines;
|
||||
$hunks = $change->getHunks();
|
||||
if ($hunks) {
|
||||
foreach ($hunks as $hunk) {
|
||||
$dhunk = new DifferentialHunk();
|
||||
$dhunk->setOldOffset($hunk->getOldOffset());
|
||||
$dhunk->setOldLen($hunk->getOldLength());
|
||||
$dhunk->setNewOffset($hunk->getNewOffset());
|
||||
$dhunk->setNewLen($hunk->getNewLength());
|
||||
$dhunk->setChanges($hunk->getCorpus());
|
||||
$changeset->addUnsavedHunk($dhunk);
|
||||
$add_lines += $hunk->getAddLines();
|
||||
$del_lines += $hunk->getDelLines();
|
||||
$lines += $add_lines + $del_lines;
|
||||
}
|
||||
} else {
|
||||
// This happens when you add empty files.
|
||||
$changeset->attachHunks(array());
|
||||
}
|
||||
|
||||
$changeset->setOldFile($change->getOldPath());
|
||||
|
|
Loading…
Reference in a new issue