aboutsummaryrefslogtreecommitdiff
path: root/contrib/pre-commit
diff options
context:
space:
mode:
authorBenjamin C Meyer <ben@meyerhome.net>2013-02-06 18:32:40 -0800
committerBenjamin C Meyer <ben@meyerhome.net>2013-02-06 18:32:40 -0800
commit33426ff725457ab20171ebdefc74f53acf2dd21b (patch)
treeee9d718fb8c93f3d80ef73e19f78619c576d599a /contrib/pre-commit
parent6e5c8604d8ae523f824980b629fc18424d325b90 (diff)
parent97398f056de99ec3b590e0a08068d4f121b8b1ff (diff)
downloadgit-hooks-33426ff725457ab20171ebdefc74f53acf2dd21b.tar.gz
git-hooks-33426ff725457ab20171ebdefc74f53acf2dd21b.tar.bz2
Merge pull request #14 from pblack/copyrights_with_entity
Augmenting the copyright_year check to be able to check that a copyright...
Diffstat (limited to 'contrib/pre-commit')
-rwxr-xr-xcontrib/pre-commit/copyright_year25
1 files changed, 20 insertions, 5 deletions
diff --git a/contrib/pre-commit/copyright_year b/contrib/pre-commit/copyright_year
index cea0fe6..514d032 100755
--- a/contrib/pre-commit/copyright_year
+++ b/contrib/pre-commit/copyright_year
@@ -1,6 +1,7 @@
#!/bin/bash
#
# Copyright (c) 2010, Benjamin C. Meyer <ben@meyerhome.net>
+# Copyright (c) 2013, Phil Black-Knight <pblack88@gmail.com>
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -31,17 +32,31 @@ function test_file {
if grep 'Copyright ' "${file}" | grep -v grep >/dev/null
then
year=`date +%Y`
- grep 'Copyright ' "${file}" | grep "${year}" >/dev/null
- if [ $? -ne 0 ] ; then
- echo "Error: $file seems to be missing a copyright string with the year $year in it.";
- exit 1
+ cr_holder=`git config --get hooks.copyrightholder`
+ if [ -n "${cr_holder}" ]
+ then
+ grep 'Copyright ' "${file}" | grep "${year}" | grep "${cr_holder}" >/dev/null
+ if [ $? -ne 0 ] ; then
+ echo "Error: $file seems to be missing a copyright string for ${cr_holder} with the year $year in it.";
+ exit 1
+ fi
+ else
+ grep 'Copyright ' "${file}" | grep "${year}" >/dev/null
+ if [ $? -ne 0 ] ; then
+ echo "Error: $file seems to be missing a copyright string with the year $year in it.";
+ exit 1
+ fi
fi
fi
}
case "${1}" in
--about )
- echo "Check that the files have a copyright with the current year."
+ cat << EOF
+Check that the files have a copyright with the current year. If the git config key
+"hooks.copyrightholder" is set, the script will verify that in addition to the
+current year, a copyright notice exists for person/entity listed in "hooks.copyrightholder"
+EOF
;;
* )
for file in `git diff-index --cached --name-only HEAD` ; do