[Xfce4-commits] <xfce-git-hooks:master> add checking of the author name and email fields

Brian J. Tarricone noreply at xfce.org
Wed Oct 7 13:12:01 CEST 2009


Updating branch refs/heads/master
         to 24ec140c21d6734ad80298f7253fa6781d8e5e31 (commit)
       from 1bdc9bc50c2eaf7e46eff20e315a3fbf95a45358 (commit)

commit 24ec140c21d6734ad80298f7253fa6781d8e5e31
Author: Brian J. Tarricone <brian at tarricone.org>
Date:   Wed Oct 7 04:11:42 2009 -0700

    add checking of the author name and email fields

 hooks/update-01-history-integrity |   54 +++++++++++++++++++++++++++++++++++++
 1 files changed, 54 insertions(+), 0 deletions(-)

diff --git a/hooks/update-01-history-integrity b/hooks/update-01-history-integrity
index d41e567..7456816 100755
--- a/hooks/update-01-history-integrity
+++ b/hooks/update-01-history-integrity
@@ -36,6 +36,58 @@ is_fast_forward()
   return 1
 }
 
+committer_info_ok() {
+    rev=$1
+
+    [ "$rev" = "0000000000000000000000000000000000000000" ] && return 0
+
+    if git rev-parse $rev^ &>/dev/null; then
+        name=`git log --pretty=format:%an $rev^..$rev`
+        email=`git log --pretty=format:%ae $rev^..$rev`
+    else
+        name=`git log --pretty=format:%an $rev`
+        email=`git log --pretty=format:%ae $rev`
+    fi
+
+    # right now i require a space in the name.  we might want to allow
+    # people more... anonymity.  but maybe not.
+    if [ -z "$name" ] || ! echo $name | grep -q ' '; then
+        echo "Please set user.name in your git config to something sane." >&2
+        return 1
+    fi
+
+    if ! echo $email | grep -E -q '[^@]+@[^@]+\.[^@]{2,}'; then
+        echo "Email invalid; please set user.email in your git config." >&2
+        return 1
+    fi
+
+    if echo $email | grep -E -q '\(none\)|localhost|localdomain|\.local$'; then
+        echo "Email invalid; please set user.email in your git config." >&2
+        return 1
+    fi
+
+    return 0
+}
+
+committer_info_ok_range() {
+    first=$1
+    last=$2
+
+    [ "$last" = "0000000000000000000000000000000000000000" ] && return 0
+
+    if [ "$first" = "0000000000000000000000000000000000000000" ]; then
+        revlist=`git rev-list $last`
+    else
+        revlist=`git rev-list $first..$last`
+    fi
+
+    for rev in $revlist; do
+        committer_info_ok $rev || return 1
+    done
+
+    return 0
+}
+
 case $refname in
   refs/tags/*)
     # don't allow modification of existing tags
@@ -82,4 +134,6 @@ case $refname in
     ;;
 esac
 
+committer_info_ok_range $oldrev $newrev || exit 1
+
 exit 0



More information about the Xfce4-commits mailing list