hackthelobby/libcaca/caca/t/check-copyright

45 lines
1.3 KiB
Bash
Executable File
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/sh
export MAKEFLAGS=""
top_srcdir="$(make -s echo-topdir)"
#
# Check that the copyright information is valid
#
nfails=0
nfiles=0
for dir in $(make -s echo-dirs -C "${top_srcdir}"); do
if [ ! -d "${top_srcdir}/${dir}" ]; then continue; fi
for x in $(make -s echo-sources -C "${top_srcdir}/${dir}"); do
case "$x" in
*.c|*.cpp|*.h|*.m|*.php|*.cs|*.java|.py|.pl)
nfiles=$(($nfiles + 1)) ;;
*)
continue ;;
esac
if ! grep 'Copyright *\((c)\|(C)\|©\)' "${top_srcdir}/${dir}/$x" >/dev/null 2>&1; then
echo "error: ${dir}/$x lacks proper copyright information"
nfails=$(($nfails + 1))
elif [ -d "${top_srcdir}/.git" ]; then
Y="$(git log "${top_srcdir}/${dir}/$x" | head -n 3 | sed -ne 's/^Date.* \([0-9][0-9][0-9][0-9]\) .*/\1/p')"
if [ "$Y" != "" ]; then
if ! grep "$Y.*@" "${top_srcdir}/${dir}/$x" >/dev/null 2>&1; then
echo "error: ${top_srcdir}/${dir}/$x last modified in $Y, which is not in copyright"
git log "${top_srcdir}/${dir}/$x" | head -n 3 | sed 's/^/info: /'
nfails=$(($nfails + 1))
fi
fi
fi
done
done
echo "$nfiles files, $nfails errors in copyright information"
if test "$nfails" -gt "10"; then
echo "Thats too many errors, deliberately failing test"
exit 1
fi
exit 0