Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/cygwin-apps/calm.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJon Turney <jon.turney@dronecode.org.uk>2023-11-22 17:07:40 +0300
committerJon Turney <jon.turney@dronecode.org.uk>2023-11-22 17:09:42 +0300
commit23cbaac193afe222962fe12b8a5710973678b363 (patch)
treed99194abcf775a32898c1f3db64a5cab868520c2
parent24046373b914f5038e23b6821080bd3af8d810f9 (diff)
Store first msgid for announce of a srcpackage
Store the first msgid allocated for a srcpackage announce, so we can set in-reply-to and thus allow threading of subsequent announces for that package.
-rwxr-xr-xcalm/calm.py12
-rw-r--r--calm/db.py23
-rw-r--r--calm/utils.py2
3 files changed, 33 insertions, 4 deletions
diff --git a/calm/calm.py b/calm/calm.py
index 66337ab..e092468 100755
--- a/calm/calm.py
+++ b/calm/calm.py
@@ -284,9 +284,6 @@ def _announce_upload(args, scan_result, maintainer, r):
# TODO: maybe other mechanisms for getting package ChangeLog?
# NEWS inside upstream source tarball?
- # TODO: store initial msgid for a package, so we can do in-reply-to and thus
- # allow threading of announces for that package
-
# build the email
hdr = {}
hdr['From'] = maintainer.name + ' <cygwin-no-reply@cygwin.com>'
@@ -299,6 +296,10 @@ def _announce_upload(args, scan_result, maintainer, r):
hdr['Subject'] = srcpkg.orig_name + ' ' + version + (' (TEST)' if test else '')
hdr['X-Calm-Announce'] = '1'
+ irtid = db.announce_msgid_get(args, srcpkg.orig_name)
+ if irtid:
+ hdr['In-Reply-To'] = irtid
+
msg = '''
The following packages have been uploaded to the Cygwin distribution:
@@ -311,7 +312,10 @@ The following packages have been uploaded to the Cygwin distribution:
# TODO: add an attachment: sha512 hashes of packages, gpg signed?
- utils.sendmail(hdr, msg)
+ msgid = utils.sendmail(hdr, msg)
+
+ if not irtid:
+ db.announce_msgid_set(args, srcpkg.orig_name, msgid)
def _process_maintainer_uploads(scan_result, args, state, all_packages, m, basedir, desc):
diff --git a/calm/db.py b/calm/db.py
index 0aef83a..3c2f761 100644
--- a/calm/db.py
+++ b/calm/db.py
@@ -55,6 +55,11 @@ def connect(args):
replaces TEXT NOT NULL,
PRIMARY KEY (name, arch)
)''')
+ conn.execute('''CREATE TABLE IF NOT EXISTS announce_msgid
+ (srcpackage TEXT NOT NULL PRIMARY KEY,
+ msgid TEXT NOT NULL
+ )''')
+
conn.commit()
return conn
@@ -138,3 +143,21 @@ def update_missing_obsolete(args, packages, arch):
conn.execute('UPDATE missing_obsolete SET replaces = ? WHERE name = ? AND arch = ?', (' '.join(r), n, arch))
return missing_obsolete
+
+
+def announce_msgid_get(args, srcpackage):
+ msgid = None
+ with connect(args) as conn:
+ conn.row_factory = sqlite3.Row
+
+ cur = conn.execute("SELECT msgid FROM announce_msgid WHERE srcpackage = ?", (srcpackage,))
+ row = cur.fetchone()
+ if row:
+ msgid = row['msgid']
+
+ return msgid
+
+
+def announce_msgid_set(args, srcpackage, msgid):
+ with connect(args) as conn:
+ conn.execute('INSERT INTO announce_msgid (srcpackage, msgid) VALUES (?, ?)', (srcpackage, msgid))
diff --git a/calm/utils.py b/calm/utils.py
index 47085fd..26e3655 100644
--- a/calm/utils.py
+++ b/calm/utils.py
@@ -196,3 +196,5 @@ def sendmail(hdr, msg):
with subprocess.Popen(['/usr/sbin/sendmail', '-t', '-oi', '-f', hdr['From']], stdin=subprocess.PIPE) as p:
p.communicate(m.as_bytes())
logging.debug('sendmail: msgid %s, exit status %d' % (m['Message-Id'], p.returncode))
+
+ return m['Message-Id']