Skip to content

Commit f13130f

Browse files
committed
Improve commit files retrieval and update tests
- Update BaseCodeAnalyzerPreCommitHook.php to use getStaged() instead of getAddedToCommit() for better accuracy in obtaining commit files. - Modify test descriptions and method calls in BaseCodeAnalyzerPreCommitHookTest.php to reflect the changes made to the main file.
1 parent 488d3e7 commit f13130f

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/Console/Commands/Hooks/BaseCodeAnalyzerPreCommitHook.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ public function __construct()
7474
*/
7575
public function handleCommittedFiles(ChangedFiles $files, Closure $next)
7676
{
77-
$commitFiles = $files->getAddedToCommit();
77+
$commitFiles = $files->getStaged();
7878

7979
if ($commitFiles->isEmpty() || GitHooks::isMergeInProgress()) {
8080
return $next($files);

tests/Features/Commands/Hooks/BaseCodeAnalyzerPreCommitHookTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
$this->initializeTempDirectory(base_path('temp'));
1010
});
1111

12-
test('Skips check if there are no files added to commit', function () {
12+
test('Skips check if there are no staged files in commit', function () {
1313
$changedFiles = mock(ChangedFiles::class)
14-
->shouldReceive('getAddedToCommit')
14+
->shouldReceive('getStaged')
1515
->andReturn(collect())
1616
->getMock();
1717

0 commit comments

Comments
 (0)