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

Daniel P. Berrangé posted 1 patch 4 years, 2 months ago
Failed in applying to current master (apply log)
update | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
[hooks PATCH v2] Don't allow @localhost email addresses in commit message
Posted by Daniel P. Berrangé 4 years, 2 months ago
Signed-off-by: Daniel P. Berrangé <berrange@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

Re: [hooks PATCH v2] Don't allow @localhost email addresses in commit message
Posted by Ján Tomko 4 years, 2 months ago
On Wed, Feb 05, 2020 at 03:25:08PM +0000, Daniel P. Berrangé wrote:
>Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
>---
> update | 17 +++++++++++++++++
> 1 file changed, 17 insertions(+)
>

Reviewed-by: Ján Tomko <jtomko@redhat.com>

Jano
Re: [hooks PATCH v2] Don't allow @localhost email addresses in commit message
Posted by Andrea Bolognani 4 years, 2 months ago
On Wed, 2020-02-05 at 15:25 +0000, Daniel P. Berrangé wrote:
> Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
> ---
>  update | 17 +++++++++++++++++
>  1 file changed, 17 insertions(+)

Reviewed-by: Andrea Bolognani <abologna@redhat.com>

-- 
Andrea Bolognani / Red Hat / Virtualization