Last active
February 2, 2019 13:12
-
-
Save valllllll2000/40adc2ff2eb9e39b73ef83758f71dc26 to your computer and use it in GitHub Desktop.
Check if copyright statements include the current year, place in .git/hooks folder
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Check if copyright statements include the current year | |
files=`git diff --cached --name-only` | |
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment