summaryrefslogtreecommitdiff
path: root/Scripts
diff options
context:
space:
mode:
authorErik de Castro Lopo <erikd@mega-nerd.com>2014-04-19 21:17:29 +1000
committerErik de Castro Lopo <erikd@mega-nerd.com>2014-04-19 21:17:54 +1000
commitaad405316803bf6f757f670f34a0ffd764105ac8 (patch)
tree7ffb2733d0a175cee05cec56cc81b4c8729bd970 /Scripts
parent080dcdafa579464fc6bec85e439d2b5878e2a8ad (diff)
Scripts/git-pre-commit-hook : Tweaks.
Diffstat (limited to 'Scripts')
-rwxr-xr-xScripts/git-pre-commit-hook60
1 files changed, 30 insertions, 30 deletions
diff --git a/Scripts/git-pre-commit-hook b/Scripts/git-pre-commit-hook
index 6df1308..2d48f1a 100755
--- a/Scripts/git-pre-commit-hook
+++ b/Scripts/git-pre-commit-hook
@@ -14,28 +14,16 @@ files=$(git diff-index --name-status --cached HEAD | grep -v ^D | sed -r "s/^[A-
exec 1>&2
#-------------------------------------------------------------------------------
-# Check the copyright notice of all files to be commited.
-
-user=`git config --global user.email`
-year=`date +"%Y"`
-
-missing_copyright_year=""
-if test $user = "erikd@mega-nerd.com" ; then
- for f in $files ; do
- if test `head -5 $f | grep -c -i copyright` -gt 0 ; then
- user_copyright=`grep -i copyright $f | grep $user | grep -c $year`
- if test $user_copyright -lt 1 ; then
- missing_copyright_year="$missing_copyright_year $f"
- fi
- fi
- done
- fi
+# Prevent files with non-ascii filenames from being committed.
-if test -n "$missing_copyright_year" ; then
- echo "Missing current year in the copyright notice of the following files:"
- for f in $missing_copyright_year ; do
- echo " $f"
- done
+if test $(git diff --cached --name-only --diff-filter=A -z $against | LC_ALL=C tr -d '[ -~]\0' | wc -c) != 0 ; then
+ echo "Error: Attempt to add a non-ascii file name."
+ echo
+ echo "This can cause problems if you want to work"
+ echo "with people on other platforms."
+ echo
+ echo "To be portable it is advisable to rename the file ..."
+ echo
echo "Commit aborted."
exit 1
fi
@@ -62,16 +50,28 @@ if test -n "$cfiles" ; then
fi
#-------------------------------------------------------------------------------
-# Prevent files with non-ascii filenames from being committed.
+# Check the copyright notice of all files to be commited.
-if test $(git diff --cached --name-only --diff-filter=A -z $against | LC_ALL=C tr -d '[ -~]\0' | wc -c) != 0 ; then
- echo "Error: Attempt to add a non-ascii file name."
- echo
- echo "This can cause problems if you want to work"
- echo "with people on other platforms."
- echo
- echo "To be portable it is advisable to rename the file ..."
- echo
+user=`git config --global user.email`
+year=`date +"%Y"`
+
+missing_copyright_year=""
+if test $user = "erikd@mega-nerd.com" ; then
+ for f in $files ; do
+ if test `head -5 $f | grep -i copyright | grep -c -i $user` -gt 0 ; then
+ user_copyright=`grep -i copyright $f | grep $user | grep -c $year`
+ if test $user_copyright -lt 1 ; then
+ missing_copyright_year="$missing_copyright_year $f"
+ fi
+ fi
+ done
+ fi
+
+if test -n "$missing_copyright_year" ; then
+ echo "Missing current year in the copyright notice of the following files:"
+ for f in $missing_copyright_year ; do
+ echo " $f"
+ done
echo "Commit aborted."
exit 1
fi