|
21 | 21 |
|
22 | 22 | class GitLogParser |
23 | 23 | { |
24 | | - static function parseInto( string $lang , RevcheckFileList & $list ) |
25 | | - { |
26 | | - $cwd = getcwd(); |
27 | | - chdir( $lang ); |
28 | | - $fp = popen( "git log --name-only" , "r" ); |
29 | | - chdir( $cwd ); |
30 | | - |
31 | | - $hash = ""; |
32 | | - $date = ""; |
33 | | - $skip = false; |
34 | | - $mcnt = 0; |
35 | | - |
36 | | - while ( ( $line = fgets( $fp ) ) !== false ) |
37 | | - { |
38 | | - // new commit block |
39 | | - if ( substr( $line , 0 , 7 ) == "commit " ) |
40 | | - { |
41 | | - $hash = trim( substr( $line , 7 ) ); |
42 | | - $date = ""; |
43 | | - $skip = false; |
44 | | - $mcnt = 0; |
45 | | - continue; |
46 | | - } |
47 | | - // datetime of commit |
48 | | - if ( strpos( $line , 'Date:' ) === 0 ) |
49 | | - { |
50 | | - $line = trim( substr( $line , 5 ) ); |
51 | | - $date = strtotime( $line ); |
52 | | - continue; |
53 | | - } |
54 | | - // empty lines |
55 | | - if ( trim( $line ) == "" ) |
56 | | - continue; |
57 | | - // commit message |
58 | | - if ( str_starts_with( $line , ' ' ) ) |
59 | | - { |
60 | | - if ( LOOSE_SKIP_REVCHECK ) // See below, and https://github.com/php/doc-base/pull/132 |
61 | | - { |
62 | | - // commits with [skip-revcheck] anywhere commit message flags skip |
63 | | - if ( str_contains( $line, '[skip-revcheck]' ) ) |
64 | | - $skip = true; |
65 | | - } |
66 | | - else |
67 | | - { |
68 | | - $mcnt++; |
69 | | - // [skip-revcheck] at start of first line of commit message flags a skip |
70 | | - if ( $mcnt == 1 && str_starts_with( trim( $line ) , '[skip-revcheck]' ) ) |
71 | | - $skip = true; |
72 | | - } |
73 | | - continue; |
74 | | - } |
75 | | - // other headers |
76 | | - if ( strpos( $line , ': ' ) > 0 ) |
77 | | - continue; |
78 | | - |
79 | | - // otherwise, a filename |
80 | | - $filename = trim( $line ); |
81 | | - $info = $list->get( $filename ); |
82 | | - |
83 | | - // untracked file (deleted, renamed) |
84 | | - if ( $info == null ) |
85 | | - continue; |
86 | | - |
87 | | - $info->addGitLogData( $hash , $date , $skip ); |
88 | | - } |
89 | | - |
90 | | - pclose( $fp ); |
91 | | - } |
92 | | - |
93 | 24 | static function parseDir( string $gdir , RevcheckFileList $list ) |
94 | 25 | { |
95 | 26 | $gdir = escapeshellarg( $gdir ); |
@@ -142,19 +73,11 @@ static function parseDir( string $gdir , RevcheckFileList $list ) |
142 | 73 |
|
143 | 74 | while ( $proc->live && str_starts_with( $proc->line , ' ' ) ) |
144 | 75 | { |
145 | | - if ( LOOSE_SKIP_REVCHECK ) // https://github.com/php/doc-base/pull/132 |
146 | | - { |
147 | | - // Messages that contains [skip-revcheck] flags entire commit as ignored. |
148 | | - if ( str_contains( $proc->line , '[skip-revcheck]' ) ) |
149 | | - $skip = true; |
150 | | - } |
151 | | - else |
152 | | - { |
153 | | - // Messages that start with [skip-revcheck] flags entire commit as ignored. |
154 | | - $lcnt++; |
155 | | - if ( $lcnt == 1 && str_starts_with( trim( $line ) , '[skip-revcheck]' ) ) |
156 | | - $skip = true; |
157 | | - } |
| 76 | + // Messages that start with [skip-revcheck] flags entire commit as ignored. |
| 77 | + $lcnt++; |
| 78 | + if ( $lcnt == 1 && str_starts_with( trim( $proc->line ) , '[skip-revcheck]' ) ) |
| 79 | + $skip = true; |
| 80 | + |
158 | 81 | $proc->next(); |
159 | 82 | } |
160 | 83 |
|
|
0 commit comments