|
Revision 4369, 1.0 kB
(checked in by sam, 7 months ago)
|
|
Add the copyright unit test and update copyright information everywhere.
|
-
Property svn:executable set to
*
|
| Line | |
|---|
| 1 | #!/bin/sh |
|---|
| 2 | |
|---|
| 3 | # |
|---|
| 4 | # Check that the copyright information is valid |
|---|
| 5 | # |
|---|
| 6 | nfails=0 |
|---|
| 7 | nfiles=0 |
|---|
| 8 | for dir in $(make -s echo-dirs -C ..); do |
|---|
| 9 | if [ ! -d "../$dir" ]; then continue; fi |
|---|
| 10 | for x in $(make -s echo-sources -C ../$dir); do |
|---|
| 11 | case "$x" in |
|---|
| 12 | *.c|*.cpp|*.h|*.m|*.php|*.cs|*.java|.py|.pl) |
|---|
| 13 | nfiles=$(($nfiles + 1)) ;; |
|---|
| 14 | *) |
|---|
| 15 | continue ;; |
|---|
| 16 | esac |
|---|
| 17 | if ! grep 'Copyright *([cC])' "../$dir/$x" >/dev/null 2>&1; then |
|---|
| 18 | echo "error: $dir/$x lacks proper copyright information" |
|---|
| 19 | nfails=$(($nfails + 1)) |
|---|
| 20 | elif [ -d ../.git ]; then |
|---|
| 21 | Y="$(git log "../$dir/$x" | head -n 3 | sed -ne 's/^Date.* \([0-9][0-9][0-9][0-9]\) .*/\1/p')" |
|---|
| 22 | if [ "$Y" != "" ]; then |
|---|
| 23 | if ! grep "$Y.*@" "../$dir/$x" >/dev/null 2>&1; then |
|---|
| 24 | echo "error: $dir/$x last modified in $Y, which is not in copyright" |
|---|
| 25 | nfails=$(($nfails + 1)) |
|---|
| 26 | fi |
|---|
| 27 | fi |
|---|
| 28 | fi |
|---|
| 29 | done |
|---|
| 30 | done |
|---|
| 31 | |
|---|
| 32 | echo "$nfiles files, $nfails errors in copyright information" |
|---|
| 33 | |
|---|
| 34 | if test "$nfails" != "0"; then |
|---|
| 35 | exit 1 |
|---|
| 36 | fi |
|---|
| 37 | |
|---|
| 38 | exit 0 |
|---|