Skip to content

Commit

Permalink
Use merge-base (three dot diff) instead of direct diff for git-diff-b…
Browse files Browse the repository at this point in the history
  • Loading branch information
bdsl committed Jan 24, 2022
1 parent 4e21783 commit 6ffb41a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/Logger/GitHub/GitDiffFileProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public function provide(string $gitDiffFilter, string $gitDiffBase): string
{
$filter = $this->shellCommandLineExecutor->execute(sprintf(
'git diff %s --diff-filter=%s --name-only | grep src/ | paste -s -d "," -',
escapeshellarg($gitDiffBase),
escapeshellarg($gitDiffBase . '...HEAD'),
escapeshellarg($gitDiffFilter)
));

Expand Down
4 changes: 2 additions & 2 deletions tests/phpunit/Logger/GitHub/GitDiffFileProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,10 @@ public function test_it_throws_no_code_to_mutate_exception_when_diff_is_empty():

public function test_it_executes_diff_and_returns_filter_as_a_string(): void
{
$expectedCommandLine = 'git diff \'master\' --diff-filter=\'AM\' --name-only | grep src/ | paste -s -d "," -';
$expectedCommandLine = 'git diff \'master...HEAD\' --diff-filter=\'AM\' --name-only | grep src/ | paste -s -d "," -';

if (PHP_OS_FAMILY === 'Windows') {
$expectedCommandLine = 'git diff "master" --diff-filter="AM" --name-only | grep src/ | paste -s -d "," -';
$expectedCommandLine = 'git diff "master...HEAD" --diff-filter="AM" --name-only | grep src/ | paste -s -d "," -';
}

$shellCommandLineExecutor = $this->createMock(ShellCommandLineExecutor::class);
Expand Down

0 comments on commit 6ffb41a

Please sign in to comment.