[hooks PATCH v2] Don't allow @localhost email addresses in commit message

Daniel P. Berrangé berrange at redhat.com
Wed Feb 5 15:25:08 UTC 2020


Signed-off-by: Daniel P. Berrangé <berrange at redhat.com>
---
 update | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/update b/update
index 247b008..7f26035 100755
--- a/update
+++ b/update
@@ -41,6 +41,10 @@
 #   When this boolean is true, you may not push a merge commit to BRANCH_NAME.
 #   By default, you may.
 #
+# hooks.allowlocalhostemail
+#   When this boolean is true, commit message email addresses are
+#   allowed to refer to @localhost
+#
 # ---------------------------------------------------------------------
 # Allow people to change server-side git config in very specific ways.
 # To enable this, on the server, you must do something like the following,
@@ -264,6 +268,19 @@ if [ $check_diff = yes ]; then
 			fi
 		done
 	fi
+
+	allow_localhost_email=$(git config --bool hooks.allowlocalhostemail)
+	if [ "$allow_localhost_email" != "true" ]; then
+		for rev in `git log --format=%h $oldrev..$newrev`
+		do
+			git show $rev | grep -E '<.*@localhost.*>' >/dev/null 2>&1
+			if test $? != 0
+			then
+				echo "*** Update hook: @localhost email address is forbidden $rev" >&2
+				exit 1
+			fi
+		done
+	fi
 fi
 
 # --- Finished
-- 
2.24.1




More information about the libvir-list mailing list