Skip to content

Commit 2b9fc6b

Browse files
committed
Adding IBM license verification in check-local
This patch adds a script called check-IBM-license-header.sh that will be used in Makefile.am, check-local target, to verify if the copyright year is accurate with the info presented in git log. Signed-off-by: Daniel Henrique Barboza <[email protected]>
1 parent b3fe6ca commit 2b9fc6b

File tree

2 files changed

+34
-1
lines changed

2 files changed

+34
-1
lines changed

Makefile.am

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,12 @@ check-local:
6969
$(PEP8) --version
7070
$(PEP8) --filename '*.py,*.py.in' --exclude="$(PEP8_BLACKLIST)" .
7171
@if $(GIT) rev-parse &> /dev/null ; then \
72-
echo "git diff verification ..."; \
72+
echo "Whitespace verification ..."; \
7373
$(GIT) diff --check ; \
7474
$(GIT) diff-tree --check \
7575
'4b825dc642cb6eb9a060e54bf8d69288fbee4904' HEAD ; \
76+
echo "IBM copyright year verification ..." ; \
77+
./check-IBM-license-header.sh ; \
7678
fi
7779
@echo "Ok"
7880

check-IBM-license-header.sh

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/bin/bash
2+
3+
# Project Ginger
4+
#
5+
# Copyright IBM Corp, 2016
6+
#
7+
# This library is free software; you can redistribute it and/or
8+
# modify it under the terms of the GNU Lesser General Public
9+
# License as published by the Free Software Foundation; either
10+
# version 2.1 of the License, or (at your option) any later version.
11+
#
12+
# This library is distributed in the hope that it will be useful,
13+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15+
# Lesser General Public License for more details.
16+
#
17+
# You should have received a copy of the GNU Lesser General Public
18+
# License along with this library; if not, write to the Free Software
19+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20+
21+
for FILE in $(git grep --cached -Il '' | \
22+
grep -v '^check-IBM-license-header.sh' )
23+
do
24+
FIRST=$(git log --pretty=format:%cd --date=short $FILE | cut -d - -f 1 | sort | uniq | head -1)
25+
LAST=$(git log --pretty=format:%cd --date=short $FILE | cut -d - -f 1 | sort | uniq | tail -1)
26+
if [ $FIRST -eq $LAST ]; then
27+
sed -i s/" Copyright.*IBM.*"/" Copyright IBM Corp, "$FIRST/g $FILE
28+
else
29+
sed -i s/" Copyright.*IBM.*"/" Copyright IBM Corp, "$FIRST"-"$LAST/g $FILE
30+
fi
31+
done

0 commit comments

Comments
 (0)