File tree Expand file tree Collapse file tree 1 file changed +12
-3
lines changed Expand file tree Collapse file tree 1 file changed +12
-3
lines changed Original file line number Diff line number Diff line change @@ -248,17 +248,26 @@ protected function getChangedFiles()
248248 protected function getChangedLinesPerFile (array $ files )
249249 {
250250 $ extract = [];
251- $ pattern = '@@ -[0-9]+(?:,[0-9]+)? \+([0-9]+)(?:,([0-9]+))? @@ ' ;
251+ $ pattern = [
252+ 'basic ' => '^@@ (.*) @@ ' ,
253+ 'specific ' => '@@ -[0-9]+(?:,[0-9]+)? \+([0-9]+)(?:,([0-9]+))? @@ ' ,
254+ ];
252255
253256 foreach ($ files as $ file => $ data ) {
254257 $ command = 'git diff -U0 ' . $ this ->baseBranch . ' ' . $ this ->currentBranch . ' ' . $ file .
255- ' | grep -P ' . escapeshellarg ($ pattern );
258+ ' | grep -E ' . escapeshellarg ($ pattern ['basic ' ]);
259+
256260 $ lineDiff = shell_exec ($ command );
257261 $ lines = array_filter (explode (PHP_EOL , $ lineDiff ));
258262 $ linesChanged = [];
259263
260264 foreach ($ lines as $ line ) {
261- preg_match ('/ ' . $ pattern . '/ ' , $ line , $ matches );
265+ preg_match ('/ ' . $ pattern ['specific ' ] . '/ ' , $ line , $ matches );
266+
267+ // If there were no specific matches, skip this line
268+ if ([] === $ matches ) {
269+ continue ;
270+ }
262271
263272 $ start = $ end = (int )$ matches [1 ];
264273
You can’t perform that action at this time.
0 commit comments