1
mirror of https://invent.kde.org/network/falkon.git synced 2024-09-21 09:42:10 +02:00

[git-hooks] New hook for checking copyright year.

This commit is contained in:
nowrep 2013-01-22 23:30:59 +01:00
parent 347cebcf8a
commit a71302fbc6
2 changed files with 24 additions and 0 deletions

View File

@ -3,6 +3,7 @@
# Install hooks into .git/hooks directory
#
cp pre-commit ../.git/hooks/pre-commit
cp post-commit ../.git/hooks/post-commit
cp post-checkout ../.git/hooks/post-checkout
cp post-merge ../.git/hooks/post-merge

23
git_hooks/pre-commit Executable file
View File

@ -0,0 +1,23 @@
#!/bin/sh
#
# Check if copyright statements include the current year
# http://damien.lespiau.name/blog/2013/01/13/a-git-pre-commit
#
files=`git diff --cached --name-only | grep '[.cpp|.h]$'`
year=`date +"%Y"`
for f in $files; do
head -10 $f | grep -i copyright 2>&1 1>/dev/null || continue
if ! grep -i -e "copyright.*$year" $f 2>&1 1>/dev/null; then
missing_copyright_files="$missing_copyright_files $f"
fi
done
if [ -n "$missing_copyright_files" ]; then
echo "$year is missing in the copyright notice of the following files:"
for f in $missing_copyright_files; do
echo " $f"
done
exit 1
fi