@@ -107,6 +107,101 @@ static function parseDir( string $gdir , RevcheckFileList $list )
107107 $ proc ->skip (); // Empty Line
108108 }
109109 }
110+
111+ static function parseDir ( string $ gdir , RevcheckFileList $ list )
112+ {
113+ $ gdir = escapeshellarg ( $ gdir );
114+ $ proc = new GitLogParserProc ( "git -C $ gdir log --name-only " );
115+
116+ $ hash = "" ;
117+ $ date = "" ;
118+ $ skip = false ;
119+ $ lcnt = 0 ;
120+
121+ while ( $ proc ->live )
122+ {
123+ // Hash
124+
125+ if ( str_starts_with ( $ proc ->line , "commit " ) )
126+ {
127+ $ hash = trim ( substr ( $ proc ->line , 7 ) );
128+ $ date = "" ;
129+ $ skip = false ;
130+ $ lcnt = 0 ;
131+ $ proc ->next ();
132+ }
133+ else
134+ throw new Exception ( "Expected commit hash. " );
135+
136+ // Headers
137+
138+ while ( $ proc ->live && strlen ( trim ( $ proc ->line ) ) > 0 )
139+ {
140+ // Date
141+ if ( str_starts_with ( $ proc ->line , 'Date: ' ) )
142+ {
143+ $ line = trim ( substr ( $ proc ->line , 5 ) );
144+ $ date = strtotime ( $ line );
145+ $ proc ->next ();
146+ continue ;
147+ }
148+ // Other headers
149+ if ( $ proc ->line [0 ] != ' ' && strpos ( $ proc ->line , ': ' ) > 0 )
150+ {
151+ $ proc ->next ();
152+ continue ;
153+ }
154+ break ;
155+ }
156+
157+ $ proc ->skip (); // Empty Line
158+
159+ // Message
160+
161+ while ( $ proc ->live && str_starts_with ( $ proc ->line , ' ' ) )
162+ {
163+ if ( LOOSE_SKIP_REVCHECK ) // https://github.com/php/doc-base/pull/132
164+ {
165+ // Messages that contains [skip-revcheck] flags entire commit as ignored.
166+ if ( str_contains ( $ proc ->line , '[skip-revcheck] ' ) )
167+ $ skip = true ;
168+ }
169+ else
170+ {
171+ // Messages that start with [skip-revcheck] flags entire commit as ignored.
172+ $ lcnt ++;
173+ if ( $ lcnt == 1 && str_starts_with ( trim ( $ line ) , '[skip-revcheck] ' ) )
174+ $ skip = true ;
175+ }
176+ $ proc ->next ();
177+ }
178+
179+ $ proc ->skip (); // Empty Line
180+
181+ // Merge commits and empty files commits
182+
183+ // Merge commits are not followed with file listings.
184+ // Some normal commits also not have file listings
185+ // (see b73609198d4606621f57e165efc457f30e403217).
186+
187+ if ( str_starts_with ( $ proc ->line , "commit " ) )
188+ continue ;
189+
190+ // Files
191+
192+ while ( $ proc ->live && strlen ( trim ( $ proc ->line ) ) > 0 )
193+ {
194+ $ file = $ list ->get ( trim ( $ proc ->line ) );
195+
196+ if ( $ file != null )
197+ $ file ->addGitLogData ( $ hash , $ date , $ skip );
198+
199+ $ proc ->next ();
200+ }
201+
202+ $ proc ->skip (); // Empty Line
203+ }
204+ }
110205}
111206
112207class GitLogParserProc
0 commit comments