|
4 | 4 | # authors appears in the apache headers in the source, and that source files |
5 | 5 | # have their Apache headers. Including this mainly for documentation, as I |
6 | 6 | # doubt the issue will occur much in future. |
| 7 | +# |
| 8 | +# Also makes sure that where the filename appears in a comment at the top of the |
| 9 | +# file, e.g. as in |
| 10 | +# // somedir/some-file.cc |
| 11 | +# the filename is accurate. |
7 | 12 |
|
8 | 13 | # run this from the top level of the repo, as |
9 | 14 | # misc/maintenance/fix_apache_headers.sh |
10 | 15 |
|
11 | 16 | set -e |
12 | 17 | cd src |
13 | 18 | rm -rf tmp |
14 | | -for x in */*.{h,cc,dox}; do |
| 19 | +for x in */*.{h,cc,dox}; do |
15 | 20 | if [ $x != "util/basic-filebuf.h" ]; then |
16 | 21 | if ! grep 'COPYING for clarification' $x >/dev/null; then |
17 | 22 | echo Fixing $x; |
18 | 23 | if ! grep "Apache License" $x >/dev/null; then |
19 | 24 | echo "$0: warning: file $x may not have an Apache license header" |
20 | 25 | else |
21 | | - cp $x tmp; cat tmp | perl -ape ' if (m/Licensed under the Apache License/) { |
22 | | - print "// See ../../COPYING for clarification regarding multiple authors\n"; |
| 26 | + cp $x tmp; cat tmp | perl -ape ' if (m/Licensed under the Apache License/) { |
| 27 | + print "// See ../../COPYING for clarification regarding multiple authors\n"; |
23 | 28 | print "//\n";} ' > $x; |
24 | 29 | fi |
25 | 30 | fi |
26 | 31 | fi |
27 | 32 | done |
| 33 | + |
| 34 | +for x in */*.{h,cc,dox}; do |
| 35 | + if [ $x != "util/basic-filebuf.h" ]; then |
| 36 | + echo "// $x" | cat - <(tail -n +2 $x) >tmp |
| 37 | + if ! diff tmp $x; then |
| 38 | + if head -n 1 $x | grep -E '// [-a-z0-9_]+/[-a-z0-9_.]+$'; then |
| 39 | + echo "Fixing $x automatically" |
| 40 | + cp tmp $x |
| 41 | + else |
| 42 | + echo "**Please fix $x manually" |
| 43 | + fi |
| 44 | + fi |
| 45 | + fi |
| 46 | +done |
0 commit comments