[sysadmin-bin] Make it work with python3 for UTF-8
- From: Bartłomiej Piotrowski <bpiotrowski src gnome org>
- To: gnome-sysadmin gnome org,commits-list gnome org
- Subject: [sysadmin-bin] Make it work with python3 for UTF-8
- Date: Tue, 21 Jul 2020 13:22:09 +0000 (UTC)
commit 862cdfb95a6d40d4c2864c97bbe039d2fd600d7d
Author: Bartłomiej Piotrowski <bpiotrowski gnome org>
Date: Tue Jul 21 15:20:27 2020 +0200
Make it work with python3 for UTF-8
git/gnome-post-receive-email | 110 +++++++++++++++++++++----------------------
1 file changed, 55 insertions(+), 55 deletions(-)
---
diff --git a/git/gnome-post-receive-email b/git/gnome-post-receive-email
index 829f12c..1f003c5 100755
--- a/git/gnome-post-receive-email
+++ b/git/gnome-post-receive-email
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/python3
#
# gnome-post-receive-email - Post receive email hook for the GNOME Git repository
#
@@ -40,7 +40,7 @@ from email import Header
if socket.gethostname() == 'gitlab.gnome.org':
import gitlab
- execfile('/home/admin/secret/gitlab_ro')
+ exec(compile(open('/home/admin/secret/gitlab_ro', "rb").read(), '/home/admin/secret/gitlab_ro', 'exec'))
gl = gitlab.Gitlab('https://gitlab.gnome.org', GITLAB_PRIVATE_RO_TOKEN, api_version=4)
@@ -144,12 +144,12 @@ class RefChange(object):
if cc is None:
cc = self.cc
- if isinstance(subject, unicode):
+ if isinstance(subject, str):
subject = Header.Header(subject)
else:
subject = Header.Header(subject.decode('utf-8'))
- print >>out, s("""
+ print(s("""
To: %(recipients)s
Cc: %(cc)s
From: %(from_address)s
@@ -166,7 +166,7 @@ Content-Transfer-Encoding: 8bit
'subject': subject,
'projectshort': projectshort,
'refname': self.refname
- }
+ }, file=out)
if include_revs:
if oldrev:
@@ -178,16 +178,16 @@ Content-Transfer-Encoding: 8bit
else:
newrev = NULL_REVISION
- print >>out, s("""
+ print(s("""
X-Git-Oldrev: %(oldrev)s
X-Git-Newrev: %(newrev)s
""") % {
'oldrev': oldrev,
'newrev': newrev,
- }
+ }, file=out)
# Trailing newline to signal the end of the header
- print >>out
+ print(file=out)
def send_main_email(self):
if not self.get_needs_main_email():
@@ -332,11 +332,11 @@ class BranchChange(RefChange):
detail_note = True
else:
detail = ""
- print >>out, " " + commit_oneline(commit) + detail
+ print(" " + commit_oneline(commit) + detail, file=out)
if detail_note:
- print >>out
- print >>out, "(*) This commit already existed in another branch; no separate mail sent"
+ print(file=out)
+ print("(*) This commit already existed in another branch; no separate mail sent", file=out)
def send_extra_emails(self):
total = len(self.added_commits)
@@ -402,18 +402,18 @@ class BranchCreation(BranchChange):
def generate_body(self, out):
if len(self.added_commits) > 0:
- print >>out, s("""
+ print(s("""
The branch '%(short_refname)s' was created.
Summary of new commits:
""") % {
'short_refname': self.short_refname,
- }
+ }, file=out)
self.generate_commit_summary(out, self.added_commits)
else:
- print >>out, s("""
+ print(s("""
The branch '%(short_refname)s' was created pointing to:
%(commit_oneline)s
@@ -421,7 +421,7 @@ The branch '%(short_refname)s' was created pointing to:
""") % {
'short_refname': self.short_refname,
'commit_oneline': commit_oneline(self.newrev)
- }
+ }, file=out)
class BranchUpdate(BranchChange):
def get_project_extra(self):
@@ -453,15 +453,15 @@ class BranchUpdate(BranchChange):
return last_commit.subject[0:SUBJECT_MAX_SUBJECT_CHARS]
def generate_body_normal(self, out):
- print >>out, s("""
+ print(s("""
Summary of changes:
-""")
+"""), file=out)
self.generate_commit_summary(out, self.added_commits)
def generate_body_non_fast_forward(self, out):
- print >>out, s("""
+ print(s("""
The branch '%(short_refname)s' was changed in a way that was not a fast-forward update.
NOTE: This may cause problems for people pulling from the branch. For more information,
please see:
@@ -472,15 +472,15 @@ Commits removed from the branch:
""") % {
'short_refname': self.short_refname,
- }
+ }, file=out)
self.generate_commit_summary(out, self.removed_commits, show_details=False)
- print >>out, s("""
+ print(s("""
Commits added to the branch:
-""")
+"""), file=out)
self.generate_commit_summary(out, self.added_commits)
def generate_body(self, out):
@@ -494,11 +494,11 @@ class BranchDeletion(RefChange):
return "Deleted branch " + self.short_refname
def generate_body(self, out):
- print >>out, s("""
+ print(s("""
The branch '%(short_refname)s' was deleted.
""") % {
'short_refname': self.short_refname,
- }
+ }, file=out)
# ========================
@@ -553,7 +553,7 @@ class AnnotatedTagChange(RefChange):
# Outputs information about the new tag
def generate_tag_info(self, out):
- print >>out, s("""
+ print(s("""
Tagger: %(tagger)s
Date: %(date)s
@@ -563,7 +563,7 @@ Date: %(date)s
'tagger': self.tagger,
'date': self.date,
'message': self.message,
- }
+ }, file=out)
# We take the creation of an annotated tag as being a "mini-release-announcement"
# and show a 'git shortlog' of the changes since the last tag that was an
@@ -578,18 +578,18 @@ Date: %(date)s
if last_tag:
revision_range = last_tag + ".." + self.newrev
- print >>out, s("""
+ print(s("""
Changes since the last tag '%(last_tag)s':
""") % {
'last_tag': last_tag
- }
+ }, file=out)
else:
revision_range = self.newrev
- print >>out, s("""
+ print(s("""
Changes:
-""")
+"""), file=out)
out.write(git.shortlog(revision_range))
out.write("\n")
@@ -604,13 +604,13 @@ class AnnotatedTagCreation(AnnotatedTagChange):
return "Created tag " + self.short_refname
def generate_body(self, out):
- print >>out, s("""
+ print(s("""
The %(tag_type)s '%(short_refname)s' was created.
""") % {
'tag_type': self.get_tag_type(),
'short_refname': self.short_refname,
- }
+ }, file=out)
self.generate_tag_info(out)
class AnnotatedTagDeletion(AnnotatedTagChange):
@@ -618,7 +618,7 @@ class AnnotatedTagDeletion(AnnotatedTagChange):
return "Deleted tag " + self.short_refname
def generate_body(self, out):
- print >>out, s("""
+ print(s("""
The %(tag_type)s '%(short_refname)s' was deleted. It previously pointed to:
%(old_commit_oneline)s
@@ -626,14 +626,14 @@ The %(tag_type)s '%(short_refname)s' was deleted. It previously pointed to:
'tag_type': self.get_tag_type(),
'short_refname': self.short_refname,
'old_commit_oneline': commit_oneline(self.old_commit_id)
- }
+ }, file=out)
class AnnotatedTagUpdate(AnnotatedTagChange):
def get_subject(self):
return "Updated tag " + self.short_refname
def generate_body(self, out):
- print >>out, s("""
+ print(s("""
The tag '%(short_refname)s' was replaced with a new tag. It previously
pointed to:
@@ -649,7 +649,7 @@ New tag information:
""") % {
'short_refname': self.short_refname,
'old_commit_oneline': commit_oneline(self.old_commit_id),
- }
+ }, file=out)
self.generate_tag_info(out)
# ========================
@@ -659,35 +659,35 @@ class LightweightTagCreation(RefChange):
return "Created tag " + self.short_refname
def generate_body(self, out):
- print >>out, s("""
+ print(s("""
The lightweight tag '%(short_refname)s' was created pointing to:
%(commit_oneline)s
""") % {
'short_refname': self.short_refname,
'commit_oneline': commit_oneline(self.newrev)
- }
+ }, file=out)
class LightweightTagDeletion(RefChange):
def get_subject(self):
return "Deleted tag " + self.short_refname
def generate_body(self, out):
- print >>out, s("""
+ print(s("""
The lighweight tag '%(short_refname)s' was deleted. It previously pointed to:
%(commit_oneline)s
""") % {
'short_refname': self.short_refname,
'commit_oneline': commit_oneline(self.oldrev)
- }
+ }, file=out)
class LightweightTagUpdate(RefChange):
def get_subject(self):
return "Updated tag " + self.short_refname
def generate_body(self, out):
- print >>out, s("""
+ print(s("""
The lightweight tag '%(short_refname)s' was updated to point to:
%(commit_oneline)s
@@ -704,7 +704,7 @@ For more information, please see:
'short_refname': self.short_refname,
'commit_oneline': commit_oneline(self.newrev),
'old_commit_oneline': commit_oneline(self.oldrev)
- }
+ }, file=out)
# ========================
@@ -713,11 +713,11 @@ class InvalidRefDeletion(RefChange):
return "Deleted invalid ref " + self.refname
def generate_body(self, out):
- print >>out, s("""
+ print(s("""
The ref '%(refname)s' was deleted. It previously pointed nowhere.
""") % {
'refname': self.refname,
- }
+ }, file=out)
# ========================
@@ -731,7 +731,7 @@ class MiscCreation(MiscChange):
return "Unexpected: Created " + self.refname
def generate_body(self, out):
- print >>out, s("""
+ print(s("""
The ref '%(refname)s' was created pointing to:
%(newrev)s
@@ -743,14 +743,14 @@ This is unexpected because:
'refname': self.refname,
'newrev': self.newrev,
'message': self.message
- }
+ }, file=out)
class MiscDeletion(MiscChange):
def get_subject(self):
return "Unexpected: Deleted " + self.refname
def generate_body(self, out):
- print >>out, s("""
+ print(s("""
The ref '%(refname)s' was deleted. It previously pointed to:
%(oldrev)s
@@ -762,14 +762,14 @@ This is unexpected because:
'refname': self.refname,
'oldrev': self.oldrev,
'message': self.message
- }
+ }, file=out)
class MiscUpdate(MiscChange):
def get_subject(self):
return "Unexpected: Updated " + self.refname
def generate_body(self, out):
- print >>out, s("""
+ print(s("""
The ref '%(refname)s' was updated from:
%(newrev)s
@@ -786,7 +786,7 @@ This is unexpected because:
'oldrev': self.oldrev,
'newrev': self.newrev,
'message': self.message
- }
+ }, file=out)
# ========================
@@ -799,32 +799,32 @@ class NotesCreation(NotesChange):
return "Created " + self.short_refname + " note"
def generate_body(self, out):
- print >>out, s("""
+ print(s("""
The note '%(short_refname)s' was created.
%(commit_oneline)s
""") % {
'short_refname': self.short_refname,
'commit_oneline': commit_oneline(self.newrev)
- }
+ }, file=out)
class NotesDeletion(NotesChange):
def get_subject(self):
return "Deleted " + self.short_refname + " note"
def generate_body(self, out):
- print >>out, s("""
+ print(s("""
The note '%(short_refname)s' was deleted.
""") % {
'short_refname': self.short_refname,
- }
+ }, file=out)
class NotesUpdate(NotesChange):
def get_subject(self):
return "Updated " + self.short_refname + " note"
def generate_body(self, out):
- print >>out, s("""
+ print(s("""
The note '%(short_refname)s' was updated from:
%(old_commit)s
@@ -836,7 +836,7 @@ To:
'short_refname': self.short_refname,
'old_commit': commit_oneline(self.oldrev),
'new_commit': commit_oneline(self.newrev),
- }
+ }, file=out)
# ========================
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]