File tree Expand file tree Collapse file tree 1 file changed +16
-2
lines changed
Expand file tree Collapse file tree 1 file changed +16
-2
lines changed Original file line number Diff line number Diff line change 11<?php declare (strict_types = 1 );
22
3+ use Nette \Utils \Strings ;
34use SebastianBergmann \Diff \Differ ;
45
56require_once __DIR__ . '/../../vendor/autoload.php ' ;
2021}
2122
2223$ diffLines = explode ("\n" , file_get_contents ($ diffFile ));
23- $ differ = new Differ (new \SebastianBergmann \Diff \Output \UnifiedDiffOutputBuilder ('' ));
24+ $ differ = new Differ (new \SebastianBergmann \Diff \Output \UnifiedDiffOutputBuilder ('' , true ));
2425$ isDifferent = false ;
2526foreach ($ diffLines as $ diffLine ) {
2627 $ operation = $ diffLine [0 ];
4849 $ isDifferent = true ;
4950
5051 echo "$ path: \n" ;
51- foreach (explode ("\n" , $ stringDiff ) as $ line ) {
52+ $ startLine = 1 ;
53+ $ startContext = 1 ;
54+ foreach (explode ("\n" , $ stringDiff ) as $ i => $ line ) {
55+ $ matches = Strings::match ($ line , '/^@@ -(\d+),?(\d*) \+(\d+),?(\d*) @@/ ' );
56+ if ($ matches !== null ) {
57+ $ startLine = (int ) $ matches [1 ];
58+ $ startContext = (int ) $ matches [2 ];
59+ continue ;
60+ }
61+
62+ if ($ lineNumber < $ startLine || $ lineNumber > ($ startLine + $ startContext )) {
63+ continue ;
64+ }
65+
5266 if (str_starts_with ($ line , '+ ' )) {
5367 echo "\033[32m $ line \033[0m \n" ;
5468 } elseif (str_starts_with ($ line , '- ' )) {
You can’t perform that action at this time.
0 commit comments