From 1e6360d4c9dc5d47fb77b98ee30c2bb9c2b5acc0 Mon Sep 17 00:00:00 2001 From: Alban Browaeys Date: Mon, 18 Apr 2022 01:44:47 +0200 Subject: [PATCH 1/4] Use versioned python binary. Unversioned python binary is no more. This reverts commit 4223ad57994fe87fe0be9b80c8070c3f4b77a071 "Support both python 2 and 3". --- contrib/hooks/post-receive/mail_notifications.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/hooks/post-receive/mail_notifications.py b/contrib/hooks/post-receive/mail_notifications.py index cce9f6cbe..bee27877e 100644 --- a/contrib/hooks/post-receive/mail_notifications.py +++ b/contrib/hooks/post-receive/mail_notifications.py @@ -1,4 +1,4 @@ -#! /usr/bin/env python +#! /usr/bin/env python3 import sys import os From 88e2870920ebd5b4bf905fd29d6b11e1e6cbe067 Mon Sep 17 00:00:00 2001 From: Alban Browaeys Date: Mon, 18 Apr 2022 01:54:13 +0200 Subject: [PATCH 2/4] Unversioned python binary is not available anymore As git_mulitmail python script is still python2 only per 2to3 script set the binary to python2. --- contrib/hooks/post-receive/lib/git_multimail.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/hooks/post-receive/lib/git_multimail.py b/contrib/hooks/post-receive/lib/git_multimail.py index 8823399e7..caa550cb5 100755 --- a/contrib/hooks/post-receive/lib/git_multimail.py +++ b/contrib/hooks/post-receive/lib/git_multimail.py @@ -1,4 +1,4 @@ -#! /usr/bin/env python +#! /usr/bin/env python2 __version__ = '1.5.0' From 04a44e14d2ae01e1850fc6db45dae477b90422a9 Mon Sep 17 00:00:00 2001 From: Adrien Crivelli Date: Wed, 14 Sep 2022 15:01:28 +0200 Subject: [PATCH 3/4] git-multimail is compatible with python3 --- contrib/hooks/post-receive/lib/git_multimail.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/hooks/post-receive/lib/git_multimail.py b/contrib/hooks/post-receive/lib/git_multimail.py index caa550cb5..8811e522c 100755 --- a/contrib/hooks/post-receive/lib/git_multimail.py +++ b/contrib/hooks/post-receive/lib/git_multimail.py @@ -1,4 +1,4 @@ -#! /usr/bin/env python2 +#! /usr/bin/env python3 __version__ = '1.5.0' From 714bd887f2f1eed57608aa6bf38b8a95d26ee2d6 Mon Sep 17 00:00:00 2001 From: Adrien Crivelli Date: Wed, 14 Sep 2022 15:03:37 +0200 Subject: [PATCH 4/4] Update git-multimail to 1.6.0 Direct copy from https://github.com/git-multimail/git-multimail/blob/00b615b48663968805b2e4b28ae7d6312c5eae1a/git-multimail/git_multimail.py --- .../hooks/post-receive/lib/git_multimail.py | 28 +++++++++++++------ 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/contrib/hooks/post-receive/lib/git_multimail.py b/contrib/hooks/post-receive/lib/git_multimail.py index 8811e522c..731c9b7a7 100755 --- a/contrib/hooks/post-receive/lib/git_multimail.py +++ b/contrib/hooks/post-receive/lib/git_multimail.py @@ -1,8 +1,8 @@ #! /usr/bin/env python3 -__version__ = '1.5.0' +__version__ = '1.6.0' -# Copyright (c) 2015-2016 Matthieu Moy and others +# Copyright (c) 2015-2022 Matthieu Moy and others # Copyright (c) 2012-2014 Michael Haggerty and others # Derived from contrib/hooks/post-receive-email, which is # Copyright (c) 2007 Andy Parkins @@ -95,7 +95,7 @@ def bytes_to_str(s, errors='strict'): unicode = str def write_str(f, msg): - # Try outputing with the default encoding. If it fails, + # Try outputting with the default encoding. If it fails, # try UTF-8. try: f.buffer.write(msg.encode(sys.getdefaultencoding())) @@ -2129,7 +2129,7 @@ def call(klass, server, timeout): # equivalent to # self.smtp.ehlo() # self.smtp.starttls() - # with acces to the ssl layer + # with access to the ssl layer self.smtp.ehlo() if not self.smtp.has_extn("starttls"): raise smtplib.SMTPException("STARTTLS extension not supported by server") @@ -2148,13 +2148,13 @@ def call(klass, server, timeout): cert_reqs=ssl.CERT_NONE ) self.environment.get_logger().error( - '*** Warning, the server certificat is not verified (smtp) ***\n' + '*** Warning, the server certificate is not verified (smtp) ***\n' '*** set the option smtpCACerts ***\n' ) if not hasattr(self.smtp.sock, "read"): # using httplib.FakeSocket with Python 2.5.x or earlier self.smtp.sock.read = self.smtp.sock.recv - self.smtp.file = smtplib.SSLFakeFile(self.smtp.sock) + self.smtp.file = self.smtp.sock.makefile('rb') self.smtp.helo_resp = None self.smtp.ehlo_resp = None self.smtp.esmtp_features = {} @@ -2194,7 +2194,7 @@ def send(self, lines, to_addrs): # turn comma-separated list into Python list if needed. if is_string(to_addrs): to_addrs = [email for (name, email) in getaddresses([to_addrs])] - self.smtp.sendmail(self.envelopesender, to_addrs, msg) + self.smtp.sendmail(self.envelopesender, to_addrs, msg.encode('utf8')) except socket.timeout: self.environment.get_logger().error( '*** Error sending email ***\n' @@ -2955,10 +2955,20 @@ class ComputeFQDNEnvironmentMixin(FQDNEnvironmentMixin): def __init__(self, **kw): super(ComputeFQDNEnvironmentMixin, self).__init__( - fqdn=socket.getfqdn(), + fqdn=self.get_fqdn(), **kw ) + def get_fqdn(self): + fqdn = socket.getfqdn() + # Sometimes, socket.getfqdn() returns localhost or + # localhost.localhost, which isn't very helpful. In this case, + # fall-back to socket.gethostname() which may return an actual + # hostname. + if fqdn == 'localhost' or fqdn == 'localhost.localdomain': + fqdn = socket.gethostname() + return fqdn + class PusherDomainEnvironmentMixin(ConfigEnvironmentMixin): """Deduce pusher_email from pusher by appending an emaildomain.""" @@ -3189,7 +3199,7 @@ def __init__(self, **kw): self.COMPUTED_KEYS += ['projectdesc'] def get_projectdesc(self): - """Return a one-line descripition of the project.""" + """Return a one-line description of the project.""" git_dir = get_git_dir() try: