Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

check-copyright 1.2 KiB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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" != "0"; then
  35. exit 1
  36. fi
  37. exit 0