summaryrefslogtreecommitdiffstats
path: root/src/build/tools
diff options
context:
space:
mode:
authorIlya Smirnov <ismirno@us.ibm.com>2017-01-05 15:46:59 -0600
committerDaniel M. Crowell <dcrowell@us.ibm.com>2017-02-03 10:44:15 -0500
commit03e362b0def5ab6b2b5f3896463d1ddee311be1d (patch)
treed5e715fa7c74d80145714c257d6f216fd2d73503 /src/build/tools
parentc36ec02ce1b00b7716994e752e917d4c89e8594f (diff)
downloadtalos-hostboot-03e362b0def5ab6b2b5f3896463d1ddee311be1d.tar.gz
talos-hostboot-03e362b0def5ab6b2b5f3896463d1ddee311be1d.zip
Ensure TODOs associated with commit's RTC/CQ are addressed.
Verify-commit will throw warnings when TODO or FIXME tags are found with RTC or CQ numbers that are the same as the ones in the commit message. Change-Id: Ia1b89edfeaa99eab480d99de26397af7883798fc RTC:166676 Reviewed-on: http://ralgit01.raleigh.ibm.com/gerrit1/34454 Tested-by: Jenkins Server <pfd-jenkins+hostboot@us.ibm.com> Tested-by: FSP CI Jenkins <fsp-CI-jenkins+hostboot@us.ibm.com> Tested-by: Jenkins OP Build CI <op-jenkins+hostboot@us.ibm.com> Reviewed-by: Stephen M. Cprek <smcprek@us.ibm.com> Reviewed-by: Daniel M. Crowell <dcrowell@us.ibm.com>
Diffstat (limited to 'src/build/tools')
-rwxr-xr-xsrc/build/tools/verify-commit169
1 files changed, 169 insertions, 0 deletions
diff --git a/src/build/tools/verify-commit b/src/build/tools/verify-commit
index a48d06e38..db41b6902 100755
--- a/src/build/tools/verify-commit
+++ b/src/build/tools/verify-commit
@@ -33,8 +33,13 @@ my $projectName = $ENV{'PROJECT_NAME'};
# Relative path of import tree from project root
my $importPrefix = $ENV{'IMPORT_REL_PATH'}."/";
+my $rtcNumber = rtc_workitem_num();
+my $cqNumber = cq_workitem_num();
+
verifyPatchSet(); # Verify the patch contents.
verifyCommitMsg(); # Verify the commit message.
+verifyTodoFixme(); # Make sure there are no TODO/FIXME
+ # associated with current RTC/CQ
# Finish out the divider.
if ($issueFound)
@@ -334,6 +339,70 @@ sub verifyCommitMsg
}
}
+# sub verifyTodoFixme
+#
+# Verifies that there are no Todo or Fixme
+# tags in the code with the current commit's
+# RTC or CQ number.
+#
+sub verifyTodoFixme
+{
+ my $file;
+ my $commentText;
+ my $lineNumber;
+ # Get the list of TODO/FIXME lines in src/
+ open TODO_LIST, "egrep -rn '(TODO.*(CQ|RTC).*)|(FIXME.*(CQ|RTC).*)' src/* |"
+ or die "Cannot get the list of TODO/FIXME lines.\n";
+
+ while(my $line = <TODO_LIST>)
+ {
+ chomp $line;
+ if(check_rtc_todo_fixme($line))
+ {
+ ($file, $commentText, $lineNumber) = parse_todo_fixme_line($line);
+ strong_warning($file, $commentText, $lineNumber,
+ "TODO/FIXME tag with the same RTC number as in the current commit message.");
+ }
+ elsif(check_cq_todo_fixme($line))
+ {
+ ($file, $commentText, $lineNumber) = parse_todo_fixme_line($line);
+ strong_warning($file, $commentText, $lineNumber,
+ "TODO/FIXME tag with the same CQ number as in the current commit message.");
+ }
+ }
+}
+
+sub parse_todo_fixme_line
+{
+ my $line = shift;
+ my ($file, $lineNumber, $commentText) = split(/:/, $line, 3);
+ return ($file, $commentText, $lineNumber);
+}
+
+sub check_rtc_todo_fixme
+{
+ my $line = shift;
+ if($line =~ m/RTC\s*:*\s*([0-9]+)/ &&
+ $1 eq $rtcNumber && $rtcNumber ne "")
+ {
+ return 1;
+ }
+
+ return 0;
+}
+
+sub check_cq_todo_fixme
+{
+ my $line = shift;
+ if($line =~ m/CQ\s*:*\s*([A-Z][A-Z][0-9]+)/ &&
+ $1 eq $cqNumber && $cqNumber ne "")
+ {
+ return 1;
+ }
+
+ return 0;
+}
+
sub warning
{
my ($file, $line, $count, $statement) = @_;
@@ -345,6 +414,20 @@ sub warning
$issueFound = 1;
}
+sub strong_warning
+{
+ my ($file, $line, $count, $statement) = @_;
+
+ # Always show strong warnings
+ print "------------------------------------------------------------\n";
+ print "***WARNING: $statement\n";
+ print " $file:$count\n";
+ print " $line\n";
+
+ $issueFound = 1;
+ $warningCount++;
+}
+
sub error
{
my ($file, $line, $count, $statement) = @_;
@@ -357,3 +440,89 @@ sub error
$errorFound = 1;
}
+# sub rtc_workitem_num
+#
+# Determines the RTC WorkItem associated with a git commit.
+#
+# @param[in] commit - The git commit, or no parameter for last commit
+#
+# @return string - RTC WorkItem number (or "").
+#
+sub rtc_workitem_num
+{
+ my $commit = shift;
+ my $message;
+
+ if(defined($commit))
+ {
+ $message = git_commit_msg($commit);
+ }
+ else
+ {
+ $message = git_commit_msg("");
+ }
+
+ if ($message =~ m/RTC:\s*([0-9]+)/)
+ {
+ return $1;
+ }
+ else
+ {
+ return "";
+ }
+}
+
+
+# sub cq_workitem_num
+#
+# Determines the CQ WorkItem associated with a git commit.
+#
+# @param[in] commit - The git commit, or no parameter for last commit
+#
+# @return string - CQ WorkItem number (or "").
+#
+sub cq_workitem_num
+{
+ my $commit = shift;
+ my $message;
+
+ if(defined($commit))
+ {
+ $message = git_commit_msg($commit);
+ }
+ else
+ {
+ $message = git_commit_msg("");
+ }
+
+ if ($message =~ m/CQ:\s*([A-Z][A-Z][0-9]+)/)
+ {
+ return $1;
+ }
+ else
+ {
+ return "";
+ }
+}
+
+# sub git_commit_msg
+#
+# Get the entire commit message associated with a commit.
+#
+# @param[in] commit - The commit to examine.
+# @return string - The commit message.
+#
+sub git_commit_msg
+{
+ my $commit = shift;
+ open COMMAND, "git log -n1 --pretty=%B $commit |";
+ my $message = "";
+ while (my $line = <COMMAND>)
+ {
+ $message = $message.$line;
+ }
+ close COMMAND;
+
+ return $message;
+}
+
OpenPOWER on IntegriCloud