6
6
#
7
7
# OpenPOWER HostBoot Project
8
8
#
9
- # Contributors Listed Below - COPYRIGHT 2013,2016
9
+ # Contributors Listed Below - COPYRIGHT 2013,2017
10
10
# [+] International Business Machines Corp.
11
11
#
12
12
#
25
25
# IBM_PROLOG_END_TAG
26
26
27
27
use strict;
28
+ use Getopt::Long qw( :config pass_through) ;
28
29
29
30
my $issueFound = 0;
30
31
my $errorFound = 0;
32
+ my $warningCount = 0;
33
+ my $showAll = 0;
34
+
35
+ use constant MAX_WARNINGS => 5;
36
+ use constant MAX_CODE_LINE_LENGTH => 80;
31
37
32
38
my $projectName = $ENV {' PROJECT_NAME' };
33
39
# Relative path of import tree from project root
@@ -36,6 +42,8 @@ my $importPrefix = $ENV{'IMPORT_REL_PATH'}."/";
36
42
my $rtcNumber = rtc_workitem_num();
37
43
my $cqNumber = cq_workitem_num();
38
44
45
+ GetOptions(" show-all" => \$showAll );
46
+
39
47
verifyPatchSet(); # Verify the patch contents.
40
48
verifyCommitMsg(); # Verify the commit message.
41
49
verifyTodoFixme(); # Make sure there are no TODO/FIXME
@@ -45,6 +53,13 @@ verifyTodoFixme(); # Make sure there are no TODO/FIXME
45
53
if ($issueFound )
46
54
{
47
55
print " ------------------------------------------------------------\n " ;
56
+ my $hiddenWarnings = $warningCount - MAX_WARNINGS;
57
+ if ($hiddenWarnings > 0 && !$showAll )
58
+ {
59
+ print " $hiddenWarnings Warning(s) Hidden\n " ;
60
+ print " Run 'verify-commit --show-all'\n " ;
61
+ print " ------------------------------------------------------------\n " ;
62
+ }
48
63
}
49
64
50
65
# Return a bad RC if we found an error. Let warnings pass.
@@ -121,7 +136,7 @@ sub verifyPatchSet
121
136
# @sub verifyFileLine
122
137
#
123
138
# Checks a particular line of the file for the following issues:
124
- # * Warning: Lines longer than 80 characters, except in trace statement.
139
+ # * Warning: Lines longer than MAX_CODE_LINE_LENGTH characters, except in trace statement.
125
140
# * Warning: Trailing whitespace.
126
141
# * Warning: Tab characters outside of makefiles.
127
142
# * Warning: TODO or FIXME type tag without a corresponding RTC number.
@@ -139,21 +154,21 @@ sub verifyFileLine
139
154
}
140
155
141
156
# Check line length.
142
- if (length ($line ) > 80 )
157
+ if (length ($line ) > MAX_CODE_LINE_LENGTH )
143
158
{
144
- # Allow trace statements to slide.
145
159
if (($line =~ m / TRAC[DSFU] / ) ||
146
160
($line =~m / TS_FAIL/ ) ||
147
161
($line =~m / printk/ ) ||
148
162
($line =~m / displayf/ ) ||
149
- ($line =~ m / FAPI_(INF|IMP|ERR|DBG|SCAN)/ ))
163
+ ($line =~ m / FAPI_(INF|IMP|ERR|DBG|SCAN)/ ) ||
164
+ ($line =~ m / print/ ))
150
165
{
151
166
}
152
167
else
153
168
{
154
169
warning($file ,$line ,$count ,
155
- (sprintf " Length is more than 80 characters (%d )." ,
156
- length ($line ))
170
+ (sprintf " Length is more than %d characters (%d )." ,
171
+ MAX_CODE_LINE_LENGTH, length ($line ))
157
172
);
158
173
}
159
174
}
@@ -169,7 +184,8 @@ sub verifyFileLine
169
184
if ($line =~ m /\t / )
170
185
{
171
186
# Makefiles are ok (require tabs).
172
- if (not (($file =~ m / makefile/ ) || ($file =~ m /\. mk/ )))
187
+ if (not (($file =~ m / makefile/ ) || ($file =~ m / Makefile/ ) ||
188
+ ($file =~ m /\. mk/ )))
173
189
{
174
190
warning($file ,$line ,$count ,
175
191
" Tab character found." );
@@ -223,6 +239,7 @@ sub verifyCommitMsg
223
239
my $lineCount = 0;
224
240
my $rtcTag = " " ;
225
241
my $cqTag = " " ;
242
+ my $changeId = " " ;
226
243
my $taggedLine = " " ;
227
244
my $untaggedLine = " " ;
228
245
@@ -306,13 +323,30 @@ sub verifyCommitMsg
306
323
}
307
324
}
308
325
326
+ if ($line =~ m / ^\s *Change-Id:\s *[I][\w ] +(.*)/ )
327
+ {
328
+ if (" " ne $changeId )
329
+ {
330
+ error(" Commit Message" ,$line ,$lineCount ,
331
+ " Mulitple Change-Id's found." );
332
+ }
333
+
334
+ $changeId = $line ;
335
+ if (" " ne $1 )
336
+ {
337
+ error(" Commit Message" ,$line ,$lineCount ,
338
+ (sprintf " Change-Id format incorrect (%s )." , $1 ));
339
+ }
340
+ }
341
+
309
342
# Identify if this is a tagged line or a non-tagged line and store
310
343
# away.
311
344
if ($line =~ m / ^\s *[A-Za-z0-9\- _] +:[^:] / )
312
345
{
313
346
# We allow lines that look like tags in the topic like...
314
347
# "FOO: Adding support for BAR."
315
- if ($lineCount > 1)
348
+ # Unless the Change-Id is in the topic
349
+ if ($lineCount > 1 || ($line =~ m / Change-Id/ ))
316
350
{
317
351
$taggedLine = $line ;
318
352
}
@@ -330,6 +364,13 @@ sub verifyCommitMsg
330
364
" Neither RTC nor CQ tag found." );
331
365
}
332
366
367
+ # Error for missing Change-Id.
368
+ if (" " eq $changeId )
369
+ {
370
+ error(" Commit Message" ," <end-of-file>" ,$lineCount ,
371
+ " Change-Id not found." );
372
+ }
373
+
333
374
# Error for a mix of tag / untagged in the last section (ie. untagged
334
375
# lines in the footer).
335
376
if ((" " ne $untaggedLine ) && (" " ne $taggedLine ))
@@ -406,12 +447,17 @@ sub check_cq_todo_fixme
406
447
sub warning
407
448
{
408
449
my ($file , $line , $count , $statement ) = @_ ;
409
- print " ------------------------------------------------------------\n " ;
410
- print " WARNING: $statement \n " ;
411
- print " $file :$count \n " ;
412
- print " $line \n " ;
450
+
451
+ if ($warningCount < MAX_WARNINGS || $showAll )
452
+ {
453
+ print " ------------------------------------------------------------\n " ;
454
+ print " WARNING: $statement \n " ;
455
+ print " $file :$count \n " ;
456
+ print " $line \n " ;
457
+ }
413
458
414
459
$issueFound = 1;
460
+ $warningCount ++;
415
461
}
416
462
417
463
sub strong_warning
0 commit comments