-
Notifications
You must be signed in to change notification settings - Fork 147
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add [diff] option to default command * add path resolver for git diff * add [diff] method to PathsRepository contract. (Breaking?) * extract method for future re-use * implement new [diff] method * lint * skip duplicates * include untracked files in diff list * add tests * fixes * make stan happy
- Loading branch information
1 parent
0d8f830
commit cc904c0
Showing
5 changed files
with
161 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
<?php | ||
|
||
use App\Contracts\PathsRepository; | ||
|
||
it('determines diff files', function () { | ||
$paths = Mockery::mock(PathsRepository::class); | ||
|
||
$paths | ||
->shouldReceive('diff') | ||
->with('main') | ||
->once() | ||
->andReturn([ | ||
base_path('tests/Fixtures/without-issues-laravel/file.php'), | ||
]); | ||
|
||
$this->swap(PathsRepository::class, $paths); | ||
|
||
[$statusCode, $output] = run('default', ['--diff' => 'main']); | ||
|
||
expect($statusCode)->toBe(0) | ||
->and($output) | ||
->toContain('── Laravel', ' 1 file'); | ||
}); | ||
|
||
it('ignores the path argument', function () { | ||
$paths = Mockery::mock(PathsRepository::class); | ||
|
||
$paths | ||
->shouldReceive('diff') | ||
->once() | ||
->andReturn([ | ||
base_path('tests/Fixtures/without-issues-laravel/file.php'), | ||
]); | ||
|
||
$this->swap(PathsRepository::class, $paths); | ||
|
||
[$statusCode, $output] = run('default', [ | ||
'--diff' => 'main', | ||
'path' => base_path(), | ||
]); | ||
|
||
expect($statusCode)->toBe(0) | ||
->and($output) | ||
->toContain('── Laravel', ' 1 file'); | ||
}); | ||
|
||
it('does not abort when there are no diff files', function () { | ||
$paths = Mockery::mock(PathsRepository::class); | ||
|
||
$paths | ||
->shouldReceive('diff') | ||
->once() | ||
->andReturn([]); | ||
|
||
$this->swap(PathsRepository::class, $paths); | ||
|
||
[$statusCode, $output] = run('default', [ | ||
'--diff' => 'main', | ||
]); | ||
|
||
expect($statusCode)->toBe(0) | ||
->and($output) | ||
->toContain('── Laravel', ' 0 files'); | ||
}); | ||
|
||
it('parses nested branch names', function () { | ||
$paths = Mockery::mock(PathsRepository::class); | ||
|
||
$paths | ||
->shouldReceive('diff') | ||
->with('origin/main') | ||
->once() | ||
->andReturn([ | ||
base_path('tests/Fixtures/without-issues-laravel/file.php'), | ||
]); | ||
|
||
$this->swap(PathsRepository::class, $paths); | ||
|
||
[$statusCode, $output] = run('default', [ | ||
'--diff' => 'origin/main', | ||
]); | ||
|
||
expect($statusCode)->toBe(0) | ||
->and($output) | ||
->toContain('── Laravel', ' 1 file'); | ||
}); |