]> gitweb.fluxo.info Git - git-hooks.git/commitdiff
Augmenting the copyright_year check to be able to check that a copyright exists for...
authorPhil Black-Knight <pblack@tresys.com>
Fri, 1 Feb 2013 20:18:39 +0000 (12:18 -0800)
committerPhil Black-Knight <pblack@tresys.com>
Fri, 1 Feb 2013 20:20:34 +0000 (12:20 -0800)
contrib/pre-commit/copyright_year

index cea0fe647535b594bcec6f4e67d6ce2f08769ca6..514d032aa175edd722c03a6911f8b4c445bc46e9 100755 (executable)
@@ -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