Created
September 29, 2015 11:19
-
-
Save fblundun/a6e81a48071e47e726ab to your computer and use it in GitHub Desktop.
Script to update Snowplow copyright notices
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# This script updates copyright notices for all files in the current branch which have changed since master. | |
set -e | |
if [ -f tmp ]; | |
then | |
>&2 echo "Error - this script would overwrite the 'tmp' file" | |
exit 1 | |
fi | |
year=`date +"%Y"` | |
# Only alter the copyright range for files altered in this branch | |
git diff --diff-filter=ACMRTUXB master @ --name-only | while read -r filepath; do | |
cat $filepath | | |
# Update copyright notices which already have a range of dates ("2012-2013" -> "2012-2015") | |
sed "/$year/b; s/Copyright (c) \([0-9]*\)-[0-9]* Snowplow Analytics Ltd/Copyright (c) \1-$year Snowplow Analytics Ltd/" | | |
# Update copyright notices which have a single date ("2012" -> "2012-2015") | |
sed "/$year/b; s/Copyright (c) \([0-9]*\) Snowplow Analytics Ltd/Copyright (c) \1-$year Snowplow Analytics Ltd/" > tmp; | |
mv tmp $filepath; | |
done |
Warning: this script may alter file permissions!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This doesn't seem to work for me on OS X - the branching directive isn't recognised. Use this instead: