From d013ada32cde6821cd43575ea508e5d1bd893eca Mon Sep 17 00:00:00 2001 From: Mike Gerwitz Date: Mon, 6 Jan 2014 21:41:04 -0500 Subject: [PATCH] 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. --- tools/copyright | 36 ++++++++++++++++++++++-------------- 1 file changed, 22 insertions(+), 14 deletions(-) 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'