Skip to content

Commit

Permalink
Minor fixes to addCopyright and pre-commit hooks
Browse files Browse the repository at this point in the history
Fixes:
- Undefined variable warning when a prolog has no copyright years.
- Literal variable name used instead of variable value.
- Unnecessary error exit when error (file not found) is a valid
  scenario.
- pre-commit hooks not ran on files that have been renamed.

Change-Id: I69ab4db934b38a44b0ac46730556c01a649fa827
Reviewed-on: http://rchgit01.rchland.ibm.com/gerrit1/92649
Tested-by: Jenkins Server <pfd-jenkins+hostboot@us.ibm.com>
Tested-by: Jenkins OP Build CI <op-jenkins+hostboot@us.ibm.com>
Reviewed-by: Benjamen G Tyner <ben.tyner@ibm.com>
Reviewed-by: Caleb N Palmer <cnpalmer@us.ibm.com>
Reviewed-by: Brian J Stegmiller <bjs@us.ibm.com>
Reviewed-by: Zane C Shelley <zshelle@us.ibm.com>
Reviewed-on: http://rchgit01.rchland.ibm.com/gerrit1/92850
Tested-by: Jenkins OP HW <op-hw-jenkins+hostboot@us.ibm.com>
Tested-by: FSP CI Jenkins <fsp-CI-jenkins+hostboot@us.ibm.com>
  • Loading branch information
zane131 committed Mar 6, 2020
1 parent c16b087 commit b684d89
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 27 deletions.
28 changes: 5 additions & 23 deletions src/build/tools/addCopyright
Expand Up @@ -693,37 +693,19 @@ sub createYearString($)
my ( $filename ) = @_;

# The list of years starts with the years in the current prolog and the
# current release year.
my @years = ();

# Get size of array @CopyRightYears
my $size = @CopyRightYears;
if ( $size < 2 ) ## If less than 2 then date entry has only a year mentioned
{
@years = @CopyRightYears;
# add current year if not already in list
if ( ($years[0] ne $ReleaseYear) )
{
push @years, $ReleaseYear ;
}
}
else
{
@years = ( @CopyRightYears, $ReleaseYear );
}
# current release year. Note that duplicates will be stripped later.
my @years = ( @CopyRightYears, $ReleaseYear );

## Make a call to git to find the earliest commit date of the file
## new files will not have a log, so the "git log" call above will
## return nothing.
## Push any year we find onto the @years array
my $cmd = 'git log -n1 -- $filename | grep "Date" ';
my $cmd = "git log -n1 -- $filename | grep 'Date' ";
## print "run $cmd\n";
my @logstrings = split( " ", `$cmd` );
if ( $? ) { die "ERROR $? : Could not run $cmd $!\n"; }

if ( scalar(@logstrings) >= 5 )
if ( not $? and (5 <= scalar @logstrings) )
{
push @years, $logstrings[5] ;
push @years, $logstrings[5];
}

# Get a unique list of years and sort the list.
Expand Down
4 changes: 2 additions & 2 deletions src/build/tools/pre-commit-actions
Expand Up @@ -6,7 +6,7 @@
#
# OpenPOWER HostBoot Project
#
# Contributors Listed Below - COPYRIGHT 2015,2018
# Contributors Listed Below - COPYRIGHT 2015,2020
# [+] International Business Machines Corp.
#
#
Expand All @@ -32,7 +32,7 @@ my $xmlSortingScript = "applyTargetingStyle";

## Make up a list of all staged files ( --cached --name-only )
## Filter for only Added or Modified ( --diff-filter=AM )
chomp( my @fileList = `git diff --cached --name-only --diff-filter=AM` );
chomp( my @fileList = `git diff --cached --name-only --diff-filter=AMR` );


if ( @fileList )
Expand Down
4 changes: 2 additions & 2 deletions src/build/tools/pre-commit-prologs
Expand Up @@ -6,7 +6,7 @@
#
# OpenPOWER HostBoot Project
#
# Contributors Listed Below - COPYRIGHT 2011,2016
# Contributors Listed Below - COPYRIGHT 2011,2020
# [+] International Business Machines Corp.
#
#
Expand All @@ -30,7 +30,7 @@ my $script = "addCopyright";

## Make up a list of all staged files ( --cached --name-only )
## Filter for only Added or Modified ( --diff-filter=AM )
chomp( my @fileList = `git diff --cached --name-only --diff-filter=AM` );
chomp( my @fileList = `git diff --cached --name-only --diff-filter=AMR` );

if ( @fileList )
{
Expand Down

0 comments on commit b684d89

Please sign in to comment.