diff options
author | Jon Turney <jon.turney@dronecode.org.uk> | 2023-08-16 15:51:37 +0300 |
---|---|---|
committer | Jon Turney <jon.turney@dronecode.org.uk> | 2023-08-20 20:42:48 +0300 |
commit | f5a68e0073ccfa5e7b339d77d77376b134961f99 (patch) | |
tree | 0adccf214f6860b96b697906cb4e2b9d6f0c3edf | |
parent | 0e2738cbfd177fcb4d0d99f330ea3469e3e052d4 (diff) |
Also allow announce message to be determined by cygport
-rwxr-xr-x | calm/calm.py | 68 |
1 files changed, 41 insertions, 27 deletions
diff --git a/calm/calm.py b/calm/calm.py index 0ed44ff..45fa09b 100755 --- a/calm/calm.py +++ b/calm/calm.py @@ -171,6 +171,9 @@ def process_uploads(args, state): m = mlist[r.user] with logfilters.AttrFilter(maint=m.name): announce = ('announce' in r.tokens) and ('noannounce' not in r.tokens) + if announce and r.announce: + announce = r.announce + return process_maintainer_uploads(args, state, all_packages, m, os.path.join(args.stagingdir, str(r.id)), 'staging', scrub=True, announce=announce) scallywag_db.do_deploys(deploy_upload) @@ -204,7 +207,7 @@ def process_maintainer_uploads(args, state, all_packages, m, basedir, desc, scru # automatically generate announce email if requested if announce and success and any([scan_result[a].to_relarea for a in scan_result]): - _announce_upload(args, scan_result, m) + _announce_upload(args, scan_result, m, announce) # remove upload files on success in homedir, always in stagingdir for arch in common_constants.ARCHES + ['noarch', 'src']: @@ -218,7 +221,7 @@ def process_maintainer_uploads(args, state, all_packages, m, basedir, desc, scru return success -def _announce_upload(args, scan_result, maintainer): +def _announce_upload(args, scan_result, maintainer, announce): srcpkg = None pkglist = set() for arch in common_constants.ARCHES + ['noarch', 'src']: @@ -241,33 +244,44 @@ def _announce_upload(args, scan_result, maintainer): to = srcpkg.tar(version) tf = to.repopath.abspath(args.rel_area) - # look in the source tar file for a README - cl = '' - with xtarfile.open(tf, mode='r') as a: - files = a.getnames() - for readme in ['README', srcpkg.orig_name + '.README']: - fn = srcpkg.orig_name + '-' + version + '.src/' + readme - if fn in files: - logging.debug("extracting %s from archive for changelog" % readme) - - f = codecs.getreader("utf-8")(a.extractfile(fn)) - - # extract relevant part of ChangeLog - # (between one '---- .* <version> ----' and the next '----' line) - found = False - for l in f: - if not found: - if l.startswith('----') and (version in l): - cl = l - found = True - else: - if l.startswith('----'): - break - cl = cl + '\n' + l - - break + if isinstance(announce, str): + # use announce message extracted from cygport, if present + cl = announce + else: + # otherwise, look in the source tar file for one of the files we know + # contains an announce message + cl = '' + with xtarfile.open(tf, mode='r') as a: + files = a.getnames() + for readme in ['README', srcpkg.orig_name + '.README', 'ANNOUNCE']: + fn = srcpkg.orig_name + '-' + version + '.src/' + readme + if fn in files: + logging.debug("extracting %s from archive for changelog" % readme) + + f = codecs.getreader("utf-8")(a.extractfile(fn)) + + # use the contents of an ANNOUNCE file verbatim + if readme == 'ANNOUNCE': + cl = f.read() + break + + # otherwise, extract relevant part of ChangeLog from README + # (between one '---- .* <version> ----' and the next '----' line) + found = False + for l in f: + if not found: + if l.startswith('----') and (version in l): + cl = l + found = True + else: + if l.startswith('----'): + break + cl = cl + '\n' + l + + break # TODO: maybe other mechanisms for getting package ChangeLog? + # NEWS inside upstream source tarball? # build the email hdr = {} |