From 682fbef52aa03bf5920ecc422b9bdb4546f31143 Mon Sep 17 00:00:00 2001 From: Stephen Cprek Date: Mon, 30 Jun 2014 14:50:47 -0500 Subject: Fix bugs in copyright prolog script Add exists check to if statment Made sure current commiter is added to changes Change-Id: I1fa6f85827598cf2c755d1ded4610997ee8847c7 Reviewed-on: http://gfw160.aus.stglabs.ibm.com:8080/gerrit/11890 Reviewed-by: Brian Silver Tested-by: Jenkins Server Reviewed-by: A. Patrick Williams III --- src/build/tools/addCopyright.pl | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) (limited to 'src/build/tools/addCopyright.pl') diff --git a/src/build/tools/addCopyright.pl b/src/build/tools/addCopyright.pl index a49683cc9..2d42b379c 100755 --- a/src/build/tools/addCopyright.pl +++ b/src/build/tools/addCopyright.pl @@ -690,8 +690,17 @@ sub checkCopyrightBlock( $$ ) { # remove everything through [+] $_ =~ s/[^\]]*\]//; - # remove trailing comment string */ - $_ =~ s/\*\///; + # remove closing comment string depening on language + if ( filetype($filename) eq "C") + { + # remove */ + $_ =~ s/\*\///; + } + elsif ( filetype($filename) eq "xml" ) + { + # remove --> + $_ =~ s/\-\-\>//; + } # remove trailing and leading whitespace $_ =~ s/^\s+|\s+$//g; # add contributor to hash @@ -702,8 +711,10 @@ sub checkCopyrightBlock( $$ ) # Get file contributors from git log my %fileContributors = getFileContributors( $filename ); - # Make sure no extra or missing contributors - if ( (keys %fileContributors) != (keys %blockFileContributors) ) + # Make sure no extra or missing contributors by checking if the current + # contributor block matches the git log history + if ( (scalar keys %fileContributors) != + (scalar keys %blockFileContributors) ) { print STDOUT "WARNING: Extra or missing file contributors\n"; return RC_BAD_CONTRIBUTORS_BLOCK; @@ -713,7 +724,7 @@ sub checkCopyrightBlock( $$ ) while ( my ($key, $value) = each(%fileContributors) ) { # Block does not match file contributors - if ( $blockFileContributors{$key} != 1) + if ( !exists($blockFileContributors{$key}) ) { print STDOUT "WARNING: File contributors section not correct\n"; return RC_BAD_CONTRIBUTORS_BLOCK; @@ -1205,6 +1216,12 @@ sub getFileContributors( $ ) # Check file for all contributors my @gitAuthors = `git log --pretty="%aN <%aE>" -- $filename | sort | uniq`; + # Add current commiter, add < > around the email to follow the same format + # as the above array + my $curAuthorEmail = `git config user.email`; + chomp($curAuthorEmail); + my $curGitAuthor = "<".$curAuthorEmail.">"; + push(@gitAuthors, $curGitAuthor); foreach my $contributor (@gitAuthors) { my $companyExists = 0; -- cgit v1.2.1