1
0
Fork 0

Updated copyright script to include all copyright years in license templates

This increases file size even further, so eventually we may want to add
ranges. That said, it's not that significant, and helps to make the life of
the project prominant.
perfodd
Mike Gerwitz 2014-01-06 21:41:04 -05:00
parent 9563733798
commit d013ada32c
1 changed files with 22 additions and 14 deletions

View File

@ -1,7 +1,7 @@
#!/bin/bash #!/bin/bash
# Updates copyright of various source files and commits to repository # Updates copyright of various source files and commits to repository
# #
# Copyright (C) 2013 Mike Gerwitz # Copyright (C) 2013, 2014 Mike Gerwitz
# #
# This file is part of GNU ease.js. # This file is part of GNU ease.js.
# #
@ -70,12 +70,21 @@ read -p 'Are you sure you want to continue (y/N)? ' c
copyupdate() copyupdate()
{ {
years="$1" local years="$1"
file="$2" local file="$2"
sed -i "s/\(. \+Copyright (C) \).*\$/\\1$years $owner/" "$file" sed -i "s/\(. \+Copyright (C) \).*\$/\\1$years $owner/" "$file"
} }
getyears()
{
grep -vF '[copyright]' \
| cut -d' ' -f4 \
| sort -u \
| tr '\n' , \
| sed 's/,/, /g;s/, $//'
}
# have at it # have at it
for file in $files; do for file in $files; do
ext="${file##*/*.}" ext="${file##*/*.}"
@ -83,14 +92,10 @@ for file in $files; do
# determine copyrightable years from commit log and format as year1, year2, # determine copyrightable years from commit log and format as year1, year2,
# ..., yearn (TODO: join consecutive years with dash) # ..., yearn (TODO: join consecutive years with dash)
years=$( years="$(
git log --format='%aD %s' --follow -- "$file" \ git log --format='%aD %s' --follow -- "$file" \
| grep -vF '[copyright]' \ | getyears
| cut -d' ' -f4 \ )"
| sort -u \
| tr '\n' , \
| sed 's/,/, /g;s/, $//'
)
# no years, then no history # no years, then no history
if [ -z "$years" ]; then if [ -z "$years" ]; then
@ -103,10 +108,13 @@ for file in $files; do
echo "$years." echo "$years."
done done
# general files # general license templates will contain all copyright years
year="$( date +%Y )" years="$(
copyupdate "$year" license.tpl git log --format='%aD %s' \
copyupdate "$year" license-min.tpl | getyears
)"
copyupdate "$years" license.tpl
copyupdate "$years" license-min.tpl
# commit # commit
git commit -am '[copyright] Copyright update' git commit -am '[copyright] Copyright update'