diff --git a/tools/copyright b/tools/copyright index 22e7e9a..edae0a4 100755 --- a/tools/copyright +++ b/tools/copyright @@ -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'