Skip to content

Commit

Permalink
Skip empty files in diff
Browse files Browse the repository at this point in the history
Sometimes empty files are committed.
  • Loading branch information
GeoffreyDijkstra committed Sep 29, 2022
1 parent 102c992 commit 66602ae
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/Commands/CodeSniffer.php
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,10 @@ function (array $diff): array {
$results = [];

$index = preg_grep('/^@@[-+,0-9 ]+@@/', $diff);
if (empty($index)) {
return $results;
}

for ($i = 0; $i < key($index); $i++) {
unset($diff[$i]);
}
Expand Down Expand Up @@ -199,7 +203,8 @@ function (array $diff): array {
// Do nothing.
break;
default:
throw new RuntimeException('Could not parse git diff, unknown character: ' . substr($line, 0, 1));
throw new RuntimeException('Could not parse git diff, unknown character: ' . substr($line,
0, 1));
}
}

Expand Down

0 comments on commit 66602ae

Please sign in to comment.