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
# 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.
#
@ -70,12 +70,21 @@ read -p 'Are you sure you want to continue (y/N)? ' c
copyupdate()
{
years="$1"
file="$2"
local years="$1"
local file="$2"
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
for file in $files; do
ext="${file##*/*.}"
@ -83,14 +92,10 @@ for file in $files; do
# determine copyrightable years from commit log and format as year1, year2,
# ..., yearn (TODO: join consecutive years with dash)
years=$(
years="$(
git log --format='%aD %s' --follow -- "$file" \
| grep -vF '[copyright]' \
| cut -d' ' -f4 \
| sort -u \
| tr '\n' , \
| sed 's/,/, /g;s/, $//'
)
| getyears
)"
# no years, then no history
if [ -z "$years" ]; then
@ -103,10 +108,13 @@ for file in $files; do
echo "$years."
done
# general files
year="$( date +%Y )"
copyupdate "$year" license.tpl
copyupdate "$year" license-min.tpl
# general license templates will contain all copyright years
years="$(
git log --format='%aD %s' \
| getyears
)"
copyupdate "$years" license.tpl
copyupdate "$years" license-min.tpl
# commit
git commit -am '[copyright] Copyright update'