File: check_copyright.bash

package info (click to toggle)
mpich 3.3-3
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 131,836 kB
  • sloc: ansic: 975,868; cpp: 57,437; f90: 53,762; perl: 19,562; xml: 12,464; sh: 12,303; fortran: 7,875; makefile: 7,078; ruby: 126; java: 100; python: 98; lisp: 19; php: 8; sed: 4
file content (37 lines) | stat: -rwxr-xr-x 1,065 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#! /bin/bash

numfiles=`git ls-files | egrep -v '(src/openpa)' | wc -l`

count=1
for x in `git ls-files | egrep -v '(src/openpa)'` ; do

    if test ! -f $x ; then continue ; fi

    echo -n "[$count/$numfiles] $x... "
    count=$(($count + 1))

    listed=`grep "(C) [0-9]* by Argonne National Laboratory" $x | head -1 | \
	sed -e 's/.*(C) \([0-9]*\) by Argonne National Laboratory.*/\1/g'`
    if test -z "$listed" ; then
	echo "no copyright (ignoring)"
	continue
    fi
    expected=`date --date="\`git log --follow --find-copies-harder -M -C 6a1cbdcf..HEAD $x | \
		grep ^Date: | tail -1 | sed -e 's/Date: *//g' | cut -f1-5 -d' '\`" +'%Y'`

    if test $listed -le 2007 ; then
	# echo "ignoring $x because of cvs->svn migration date loss"
	echo "pre-svn (ignoring)"
	continue
    fi

    if test "$expected" != "$listed" ; then
	# echo "$x (expected: $expected; listed: $listed)"
	sed -i "s/(C) $listed by Argonne National Laboratory/(C) $expected by Argonne National Laboratory/g" $x
	echo "incorrect (fixed)"
	continue
    fi

    echo "nothing to fix"

done