add script for updating copyright years based on most recent Git commit

This commit is contained in:
Joel Dice 2012-05-11 17:43:13 -06:00
parent f94d10cbba
commit 8d57e91971

12
update-copyright.sh Normal file
View File

@ -0,0 +1,12 @@
for x in $(find -name *.S -or -name *.cpp -or -name *.h -or -name *.java | sort); do
year_of_last_change=$(git log -1 --format=format:"%ai" $x | cut -c 1-4)
copyright_years=$(grep "^/\* Copyright (c) .*, Avian Contributors$" $x | sed "s-^/\* Copyright (c) \(.*\), Avian Contributors\$-\1-")
if [ "$copyright_years" != "" ]; then
first_copyright_year=$(echo "$copyright_years" | sed "s/\(.*\)-.*/\1/")
last_copyright_year=$(echo "$copyright_years" | sed "s/.*-\(.*\)/\1/")
if [ "$last_copyright_year" != "$year_of_last_change" ]; then
echo "$first_copyright_year-$year_of_last_change $x"
sed -i "s:^/\* Copyright (c) .*, Avian Contributors\$:/* Copyright (c) $first_copyright_year-$year_of_last_change, Avian Contributors:" $x
fi
fi
done