Mercurial > hg > freeDiameter
annotate contrib/update_copyright.sh @ 1562:6219359a36a9 default tip
Merge latest changes from proposed branch
author | Sebastien Decugis <sdecugis@freediameter.net> |
---|---|
date | Mon, 21 Jun 2021 19:08:18 +0800 |
parents | c242cba52833 |
children |
rev | line source |
---|---|
0 | 1 #!/bin/bash -x |
2 | |
257
d52832097f42
Ported the script to freeDiameter
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
0
diff
changeset
|
3 # This script will search all copyrights dates from source files, and update these if |
d52832097f42
Ported the script to freeDiameter
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
0
diff
changeset
|
4 # the file has been modified at a later date. |
0 | 5 |
661
c242cba52833
Updated script for copyright
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
299
diff
changeset
|
6 if [ ! -f include/freeDiameter/libfdcore.h ]; |
257
d52832097f42
Ported the script to freeDiameter
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
0
diff
changeset
|
7 then echo "This script must be run from the source top directory" |
0 | 8 exit 1; |
9 fi; | |
10 | |
11 # Create a clean working copy | |
12 TMPDIR=`mktemp -d up_cop.XXXXXXX` || exit 1 | |
257
d52832097f42
Ported the script to freeDiameter
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
0
diff
changeset
|
13 hg clone . $TMPDIR/fD || exit 1 |
d52832097f42
Ported the script to freeDiameter
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
0
diff
changeset
|
14 pushd $TMPDIR/fD |
0 | 15 |
257
d52832097f42
Ported the script to freeDiameter
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
0
diff
changeset
|
16 # Now, for each file with a copyright |
0 | 17 for SRC_FILE in `find . -name .hg -prune -or -type f -exec grep -q 'Copyright (c) 20.., WIDE Project and NICT' {} \; -print`; |
18 do | |
19 HG_YEAR=`hg log --template '{date|shortdate}' $SRC_FILE | tr - ' ' | awk '{print \$1}'` | |
20 CPY_YEAR=`grep 'Copyright (c) 20.., WIDE Project and NICT' $SRC_FILE | awk '{print substr(\$4, 1, 4) }'` | |
21 if [ $HG_YEAR -gt $CPY_YEAR ]; | |
22 then | |
23 echo "Updating copyright $CPY_YEAR -> $HG_YEAR in $SRC_FILE"; | |
24 sed -i -e "s/Copyright (c) $CPY_YEAR, WIDE Project and NICT/Copyright (c) $HG_YEAR, WIDE Project and NICT/" $SRC_FILE | |
25 fi; | |
26 done | |
27 | |
28 hg commit -m"Updated copyright information" | |
29 hg push | |
30 popd | |
31 rm -rf $TMPDIR | |
32 hg update | |
33 |