mirror of
https://invent.kde.org/network/falkon.git
synced 2024-12-19 18:26:34 +01:00
[git-hooks] New hook for checking copyright year.
This commit is contained in:
parent
347cebcf8a
commit
a71302fbc6
@ -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
23
git_hooks/pre-commit
Executable 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
|
Loading…
Reference in New Issue
Block a user