1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-09-20 01:08:50 +02:00

Make old and new files when checking for changes by commit

Summary:
We have some false positives on commit changes checker.
I'm not sure if the reason is a difference between `git diff` and `svn diff` or something else but making this more robust doesn't harm anything.

We couldn't make the files from the whole changeset because I want to ignore context bigger than `$num_lines` to reduce rebase noise.

Test Plan:
Ran the method on diff which had false positive previously.
Ran the method on a diff with real change.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D3107
This commit is contained in:
vrana 2012-07-30 17:39:30 -07:00
parent 3c7944d297
commit 9092994e45

View file

@ -292,9 +292,27 @@ abstract class PhabricatorRepositoryCommitMessageParserWorker
if ($files[$file_phid]->loadFileData() != $corpus) {
return $vs_diff;
}
} else if ($changeset->makeChangesWithContext() !=
$vs_changeset->makeChangesWithContext()) {
return $vs_diff;
} else {
$context = implode("\n", $changeset->makeChangesWithContext());
$vs_context = implode("\n", $vs_changeset->makeChangesWithContext());
// We couldn't just compare $context and $vs_context because following
// diffs will be considered different:
//
// -(empty line)
// -echo 'test';
// (empty line)
//
// (empty line)
// -echo "test";
// -(empty line)
$hunk = id(new DifferentialHunk())->setChanges($context);
$vs_hunk = id(new DifferentialHunk())->setChanges($vs_context);
if ($hunk->makeOldFile() != $vs_hunk->makeOldFile() ||
$hunk->makeNewFile() != $vs_hunk->makeNewFile()) {
return $vs_diff;
}
}
}