Skip to content

Commit

Permalink
display file name in the diff output
Browse files Browse the repository at this point in the history
Signed-off-by: rahul <[email protected]>

Signed-off-by: rahul <[email protected]>
  • Loading branch information
rcsofttech85 committed Sep 9, 2023
1 parent f33a183 commit 3bc869d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions bin/file-diff
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,10 @@ function fileDiff($oldFilePath, $newFilePath)
$newLineNumber = $i + 1;


$changes[] = ($oldLine === null ? "$colorGreen+ New (Line $newLineNumber): " : "$colorRed- Old (Line $oldLineNumber): ") . ($oldLine ?? $newLine) . "$colorReset";
$changes[] = ($oldLine === null ? "$colorGreen+ $newFilePath (Line $newLineNumber): " : "$colorRed- $oldFilePath (Line $oldLineNumber): ") . ($oldLine ?? $newLine) . "$colorReset";

if ($oldLine !== null && $newLine !== null) {
$changes[] = "$colorGreen+ New (Line $newLineNumber): " . $newLine . "$colorReset";
$changes[] = "$colorGreen+ $newFilePath (Line $newLineNumber): " . $newLine . "$colorReset";
}
}

Expand Down
6 changes: 3 additions & 3 deletions tests/Integration/FileDiffCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ public static function commandArgumentProvider(): iterable
file_put_contents("new", "this line has same old code" . PHP_EOL, FILE_APPEND);


yield ['old', 'new', 'Old (Line 1):'];
yield ['old', 'new', 'Old (Line 2):'];
yield ['old', 'new', 'old (Line 1):'];
yield ['old', 'new', 'old (Line 2):'];
}

public static function matchingDataProvider(): iterable
Expand All @@ -35,7 +35,7 @@ public static function matchingDataProvider(): iterable
file_put_contents("new", "this has matching content" . PHP_EOL, FILE_APPEND);


yield ['old', 'new', 'Old (Line 3):'];
yield ['old', 'new', 'old (Line 3):'];
}

#[Test]
Expand Down

0 comments on commit 3bc869d

Please sign in to comment.