mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-28 00:10:57 +01:00
Trim lines before detecting copied/moved code
Test Plan: https://secure.phabricator.com/differential/diff/4043/ {F10761} Reviewers: epriestley Reviewed By: epriestley CC: aran, Koolvin Differential Revision: https://secure.phabricator.com/D2352
This commit is contained in:
parent
4cc61687aa
commit
2f047dce43
1 changed files with 3 additions and 3 deletions
|
@ -156,7 +156,7 @@ final class DifferentialDiff extends DifferentialDAO {
|
|||
return $diff;
|
||||
}
|
||||
|
||||
public function detectCopiedCode($min_width = 40, $min_lines = 3) {
|
||||
public function detectCopiedCode($min_width = 30, $min_lines = 3) {
|
||||
$map = array();
|
||||
$files = array();
|
||||
$types = array();
|
||||
|
@ -167,7 +167,7 @@ final class DifferentialDiff extends DifferentialDAO {
|
|||
foreach (explode("\n", $hunk->getChanges()) as $code) {
|
||||
$type = (isset($code[0]) ? $code[0] : '');
|
||||
if ($type == '-' || $type == ' ') {
|
||||
$code = (string)substr($code, 1);
|
||||
$code = trim(substr($code, 1));
|
||||
$files[$file][$line] = $code;
|
||||
$types[$file][$line] = $type;
|
||||
if (strlen($code) >= $min_width) {
|
||||
|
@ -182,7 +182,7 @@ final class DifferentialDiff extends DifferentialDAO {
|
|||
foreach ($this->changesets as $changeset) {
|
||||
$copies = array();
|
||||
foreach ($changeset->getHunks() as $hunk) {
|
||||
$added = $hunk->getAddedLines();
|
||||
$added = array_map('trim', $hunk->getAddedLines());
|
||||
for (reset($added); list($line, $code) = each($added); next($added)) {
|
||||
if (isset($map[$code])) { // We found a long matching line.
|
||||
$best_length = 0;
|
||||
|
|
Loading…
Reference in a new issue