diff options
author | Patrick Ohly <patrick.ohly@intel.com> | 2009-03-25 15:21:04 +0100 |
---|---|---|
committer | Patrick Ohly <patrick.ohly@intel.com> | 2009-03-25 15:21:04 +0100 |
commit | 25a8502a4bdeb9421f744860f5fdd7162f549c23 (patch) | |
tree | 517d37ad301810a6437d46ce50338b30942ecf23 /build | |
parent | dae1b8854dbcbe023b8b9739a325e33330a0cb78 (diff) |
copyright updated
update-copyright.sh can be used to add copyright remarks for the current
year. It finds the authors who made a change in each file and adds/updates
their copyright remark. Intel employees are grouped under "Intel Corporation".
Diffstat (limited to 'build')
-rwxr-xr-x | build/update-copyrights.sh | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/build/update-copyrights.sh b/build/update-copyrights.sh new file mode 100755 index 00000000..39c34bc2 --- /dev/null +++ b/build/update-copyrights.sh @@ -0,0 +1,50 @@ +#! /bin/sh +# +# Usage: update-copyrights.sh "author" <files/dirs> + +currentyear=`date +%Y` +oldyear=`expr $currentyear - 1` +export currentyear oldyear author + +addcopyright () { + file="$1" + author="$2" + + if grep -w "Copyright.*$currentyear.*$author" $file >/dev/null; then + # done + true + elif grep -w "Copyright.*-$oldyear $author" $file >/dev/null; then + # replace end year + perl -pi -e 's/-$ENV{oldyear} $ENV{author}/-$ENV{currentyear} $ENV{author}/' $file + echo updated: $author: $file + elif grep -w "Copyright.*$oldyear $author" $file >/dev/null; then + # add consecutive year + perl -pi -e 's/$ENV{oldyear} $ENV{author}/$ENV{oldyear}-$ENV{currentyear} $ENV{author}/' $file + echo updated: $author: $file + elif grep -w "Copyright.*$author" $file >/dev/null; then + # add separate year + perl -pi -e 's/(Copyright.*) $ENV{author}/$1, $ENV{currentyear} $ENV{author}/' $file + echo updated: $author: $file + elif grep -w "Copyright" $file >/dev/null; then + # add new line after the last copyright line + # -i doesn't work with reading all lines? + perl -e '$_ = join ("", <>); s/(.*)((^[ *#]*Copyright)[^\n]*)/$1$2\n$3 (C) $ENV{currentyear} $ENV{author}/ms; print;' \ + $file >$file.bak && mv $file.bak $file && echo added: $author: $file || + rm $file.bak && echo no copyright: $author: $file + else + echo skipped: $author: $file + fi +} + +for file in `git ls-files "$@"`; do + git log --since=2009-01-01 --pretty='format:%ai: %an <%ae>' $file | + grep ^$currentyear | + sed -e 's/.*: //' | + sort -u | + while read author; do + case $author in *intel.com*) + author="Intel Corporation" + esac + addcopyright "$file" "$author" + done +done |