You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

45 lines
1.3 KiB

  1. #!/bin/sh
  2. export MAKEFLAGS=""
  3. top_srcdir="$(make -s echo-topdir)"
  4. #
  5. # Check that the copyright information is valid
  6. #
  7. nfails=0
  8. nfiles=0
  9. for dir in $(make -s echo-dirs -C "${top_srcdir}"); do
  10. if [ ! -d "${top_srcdir}/${dir}" ]; then continue; fi
  11. for x in $(make -s echo-sources -C "${top_srcdir}/${dir}"); do
  12. case "$x" in
  13. *.c|*.cpp|*.h|*.m|*.php|*.cs|*.java|.py|.pl)
  14. nfiles=$(($nfiles + 1)) ;;
  15. *)
  16. continue ;;
  17. esac
  18. if ! grep 'Copyright *\((c)\|(C)\|©\)' "${top_srcdir}/${dir}/$x" >/dev/null 2>&1; then
  19. echo "error: ${dir}/$x lacks proper copyright information"
  20. nfails=$(($nfails + 1))
  21. elif [ -d "${top_srcdir}/.git" ]; then
  22. Y="$(git log "${top_srcdir}/${dir}/$x" | head -n 3 | sed -ne 's/^Date.* \([0-9][0-9][0-9][0-9]\) .*/\1/p')"
  23. if [ "$Y" != "" ]; then
  24. if ! grep "$Y.*@" "${top_srcdir}/${dir}/$x" >/dev/null 2>&1; then
  25. echo "error: ${top_srcdir}/${dir}/$x last modified in $Y, which is not in copyright"
  26. git log "${top_srcdir}/${dir}/$x" | head -n 3 | sed 's/^/info: /'
  27. nfails=$(($nfails + 1))
  28. fi
  29. fi
  30. fi
  31. done
  32. done
  33. echo "$nfiles files, $nfails errors in copyright information"
  34. if test "$nfails" -gt "10"; then
  35. echo "That’s too many errors, deliberately failing test"
  36. exit 1
  37. fi
  38. exit 0