Skip to content

Commit f288201

Browse files
Ilya Smirnovdcrowell77
authored andcommitted
Porting ekb verify-commit enhancements to hostboot
Change-Id: I6eccfca504b9396e1998f5999053b2b2f0908d73 Reviewed-on: http://ralgit01.raleigh.ibm.com/gerrit1/34366 Tested-by: Jenkins Server <pfd-jenkins+hostboot@us.ibm.com> Reviewed-by: Daniel M. Crowell <dcrowell@us.ibm.com>
1 parent 03e362b commit f288201

File tree

2 files changed

+61
-15
lines changed

2 files changed

+61
-15
lines changed

src/build/citest/check-copyright

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#
77
# OpenPOWER HostBoot Project
88
#
9-
# Contributors Listed Below - COPYRIGHT 2014,2015
9+
# Contributors Listed Below - COPYRIGHT 2014,2017
1010
# [+] International Business Machines Corp.
1111
#
1212
#
@@ -25,7 +25,7 @@
2525
# IBM_PROLOG_END_TAG
2626

2727
COPYRIGHT_CHECK=${PROJECT_ROOT}/src/build/tools/copyright-check.sh
28-
COMMIT_CHECK=${PROJECT_ROOT}/src/build/tools/verify-commit
28+
COMMIT_CHECK="${PROJECT_ROOT}/src/build/tools/verify-commit --show-all"
2929

3030
$COPYRIGHT_CHECK || exit -1
3131
$COMMIT_CHECK || exit -1

src/build/tools/verify-commit

Lines changed: 59 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#
77
# OpenPOWER HostBoot Project
88
#
9-
# Contributors Listed Below - COPYRIGHT 2013,2016
9+
# Contributors Listed Below - COPYRIGHT 2013,2017
1010
# [+] International Business Machines Corp.
1111
#
1212
#
@@ -25,9 +25,15 @@
2525
# IBM_PROLOG_END_TAG
2626

2727
use strict;
28+
use Getopt::Long qw(:config pass_through);
2829

2930
my $issueFound = 0;
3031
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;
3137

3238
my $projectName = $ENV{'PROJECT_NAME'};
3339
# Relative path of import tree from project root
@@ -36,6 +42,8 @@ my $importPrefix = $ENV{'IMPORT_REL_PATH'}."/";
3642
my $rtcNumber = rtc_workitem_num();
3743
my $cqNumber = cq_workitem_num();
3844

45+
GetOptions("show-all" => \$showAll);
46+
3947
verifyPatchSet(); # Verify the patch contents.
4048
verifyCommitMsg(); # Verify the commit message.
4149
verifyTodoFixme(); # Make sure there are no TODO/FIXME
@@ -45,6 +53,13 @@ verifyTodoFixme(); # Make sure there are no TODO/FIXME
4553
if ($issueFound)
4654
{
4755
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+
}
4863
}
4964

5065
# Return a bad RC if we found an error. Let warnings pass.
@@ -121,7 +136,7 @@ sub verifyPatchSet
121136
# @sub verifyFileLine
122137
#
123138
# 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.
125140
# * Warning: Trailing whitespace.
126141
# * Warning: Tab characters outside of makefiles.
127142
# * Warning: TODO or FIXME type tag without a corresponding RTC number.
@@ -139,21 +154,21 @@ sub verifyFileLine
139154
}
140155

141156
# Check line length.
142-
if (length($line) > 80)
157+
if (length($line) > MAX_CODE_LINE_LENGTH)
143158
{
144-
# Allow trace statements to slide.
145159
if (($line =~ m/TRAC[DSFU]/) ||
146160
($line =~m/TS_FAIL/) ||
147161
($line =~m/printk/) ||
148162
($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/))
150165
{
151166
}
152167
else
153168
{
154169
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))
157172
);
158173
}
159174
}
@@ -169,7 +184,8 @@ sub verifyFileLine
169184
if ($line =~ m/\t/)
170185
{
171186
# 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/)))
173189
{
174190
warning($file,$line,$count,
175191
"Tab character found.");
@@ -223,6 +239,7 @@ sub verifyCommitMsg
223239
my $lineCount = 0;
224240
my $rtcTag = "";
225241
my $cqTag = "";
242+
my $changeId = "";
226243
my $taggedLine = "";
227244
my $untaggedLine = "";
228245

@@ -306,13 +323,30 @@ sub verifyCommitMsg
306323
}
307324
}
308325

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+
309342
# Identify if this is a tagged line or a non-tagged line and store
310343
# away.
311344
if ($line =~ m/^\s*[A-Za-z0-9\-_]+:[^:]/)
312345
{
313346
# We allow lines that look like tags in the topic like...
314347
# "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/))
316350
{
317351
$taggedLine = $line;
318352
}
@@ -330,6 +364,13 @@ sub verifyCommitMsg
330364
"Neither RTC nor CQ tag found.");
331365
}
332366

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+
333374
# Error for a mix of tag / untagged in the last section (ie. untagged
334375
# lines in the footer).
335376
if (("" ne $untaggedLine) && ("" ne $taggedLine))
@@ -406,12 +447,17 @@ sub check_cq_todo_fixme
406447
sub warning
407448
{
408449
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+
}
413458

414459
$issueFound = 1;
460+
$warningCount++;
415461
}
416462

417463
sub strong_warning

0 commit comments

Comments
 (0)