From dcba92797f981bc9d6969b5def25ca246a172859 Mon Sep 17 00:00:00 2001 From: Stephen Cprek Date: Thu, 9 Oct 2014 10:08:56 -0500 Subject: Prevent duplicate contributors in the copyrightblock Git merge was causing extra contributors to be added to the copyright block. This change fixes up any duplicates. Change-Id: If70eb791a3dda8cc820656e0e761f6758736b294 Reviewed-on: http://gfw160.aus.stglabs.ibm.com:8080/gerrit/13906 Tested-by: Jenkins Server Reviewed-by: A. Patrick Williams III --- src/build/tools/addCopyright.pl | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'src/build/tools/addCopyright.pl') diff --git a/src/build/tools/addCopyright.pl b/src/build/tools/addCopyright.pl index 8c6e01d3e..04775dbac 100755 --- a/src/build/tools/addCopyright.pl +++ b/src/build/tools/addCopyright.pl @@ -417,7 +417,6 @@ sub update( $$ ) if ( $opt_debug ) { print STDERR __LINE__, ": fill in new copyright block...\n"; } fillinEmptyCopyrightBlock( $filename, $filetype ); - } ## return OK by default. @@ -656,7 +655,8 @@ sub checkCopyrightBlock( $$ ) ## split into lines and check for specific things ## $Source: src/usr/initservice/istepdispatcher/istepdispatcher.H $ - my %blockFileContributors = (); + my %blockFileContributorsHash = (); + my $numBlockEntries = 0; for ( split /^/, $block ) { chomp( $_ ); @@ -706,7 +706,8 @@ sub checkCopyrightBlock( $$ ) # remove trailing and leading whitespace $_ =~ s/^\s+|\s+$//g; # add contributor to hash - $blockFileContributors{$_} = 1; + $blockFileContributorsHash{$_} = 1; + $numBlockEntries++; } } ## endfor @@ -716,7 +717,7 @@ sub checkCopyrightBlock( $$ ) # 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) ) + ($numBlockEntries) ) { print STDOUT "WARNING: Extra or missing file contributors\n"; return RC_BAD_CONTRIBUTORS_BLOCK; @@ -726,7 +727,7 @@ sub checkCopyrightBlock( $$ ) while ( my ($key, $value) = each(%fileContributors) ) { # Block does not match file contributors - if ( !exists($blockFileContributors{$key}) ) + if ( !exists($blockFileContributorsHash{$key}) ) { print STDOUT "WARNING: File contributors section not correct\n"; return RC_BAD_CONTRIBUTORS_BLOCK; @@ -1075,7 +1076,7 @@ sub fillinEmptyCopyrightBlock( $$ ) # Get copyright contributors based on hash so no duplicates my %fileContributors = getFileContributors( $filename ); my $copyright_Contributors = ""; - while ( my ($key, $value) = each(%fileContributors) ) + foreach my $key (sort keys %fileContributors) { $copyright_Contributors .= "[+] ".$key."\n"; } @@ -1186,6 +1187,7 @@ EOF } } + ####################################### ## Gets file contirbutors based on git log of a file ## -- cgit v1.2.1