1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-23 22:10:55 +01:00

Ignore non-existing diffs in copied code detector script

Auditors: epriestley
This commit is contained in:
vrana 2012-04-30 11:05:30 -07:00
parent e08b4cbb2c
commit f362e5785f

View file

@ -29,17 +29,19 @@ list(, $from, $to) = $argv;
for ($diff_id = $from; $diff_id <= $to; $diff_id++) {
echo "Processing $diff_id";
$diff = id(new DifferentialDiff())->load($diff_id);
$diff->attachChangesets($diff->loadChangesets());
$orig_copy = array();
foreach ($diff->getChangesets() as $i => $changeset) {
$orig_copy[$i] = idx((array)$changeset->getMetadata(), 'copy:lines');
$changeset->attachHunks($changeset->loadHunks());
}
$diff->detectCopiedCode();
foreach ($diff->getChangesets() as $i => $changeset) {
if (idx($changeset->getMetadata(), 'copy:lines') || $orig_copy[$i]) {
echo ".";
$changeset->save();
if ($diff) {
$diff->attachChangesets($diff->loadChangesets());
$orig_copy = array();
foreach ($diff->getChangesets() as $i => $changeset) {
$orig_copy[$i] = idx((array)$changeset->getMetadata(), 'copy:lines');
$changeset->attachHunks($changeset->loadHunks());
}
$diff->detectCopiedCode();
foreach ($diff->getChangesets() as $i => $changeset) {
if (idx($changeset->getMetadata(), 'copy:lines') || $orig_copy[$i]) {
echo ".";
$changeset->save();
}
}
}
echo "\n";