From: Herton R. Krzesinski <herton@xxxxxxxxxx> redhat: add support for Jira issues in changelog Bugzilla: INTERNAL Upstream Status: RHEL only RHEL will switch from Bugzilla to Jira for tickets. This adds support for parsing and listing Jira issues in the changelog. Signed-off-by: Herton R. Krzesinski <herton@xxxxxxxxxx> diff --git a/redhat/scripts/genspec/genlog.py b/redhat/scripts/genspec/genlog.py index blahblah..blahblah 100755 --- a/redhat/scripts/genspec/genlog.py +++ b/redhat/scripts/genspec/genlog.py @@ -15,20 +15,26 @@ import re import sys -def find_bz_in_line(line, prefix): - """Return bug number from properly formated Bugzilla: line.""" - # BZs must begin with '{prefix}: ' and contain a complete BZ URL or id - _bugs = set() +def find_ticket_in_line(line, prefix, tkt_re, tkt_groups): + """Return ticket referenced in the given line""" + _tkts = set() if not line.startswith(f"{prefix}: "): - return _bugs + return _tkts + for match in tkt_re.finditer(line[len(f"{prefix}:"):]): + for group in tkt_groups: + if match.group(group): + tid = match.group(group).strip() + _tkts.add(tid) + return _tkts + +def find_bz_in_line(line, prefix): bznum_re = re.compile(r'(?P<bug_ids> \d{4,8})|' r'( http(s)?://bugzilla\.redhat\.com/(show_bug\.cgi\?id=)?(?P<url_bugs>\d{4,8}))') - for match in bznum_re.finditer(line[len(f"{prefix}:"):]): - for group in [ 'bug_ids', 'url_bugs' ]: - if match.group(group): - bid = match.group(group).strip() - _bugs.add(bid) - return _bugs + return find_ticket_in_line(line, prefix, bznum_re, [ 'bug_ids', 'url_bugs' ]) + +def find_ji_in_line(line, prefix): + ji_re = re.compile(r' https://issues\.redhat\.com/(?:browse|projects/RHEL/issues)/(?P<jira_id>RHEL-\d{1,8})\s*$') + return find_ticket_in_line(line, prefix, ji_re, [ 'jira_id' ]) def find_cve_in_line(line): """Return cve number from properly formated CVE: line.""" @@ -56,6 +62,7 @@ def parse_commit(commit): cve_set = set() bug_set = set() zbug_set = set() + jira_set = set() for line in lines[1:]: # Metadata in git notes has priority over commit log # If we found any BZ/ZBZ/CVE in git notes, we ignore commit log @@ -70,28 +77,35 @@ def parse_commit(commit): # Grab CVE tags if they are present cve_set.update(find_cve_in_line(line)) - return (log_entry, sorted(cve_set), sorted(bug_set), sorted(zbug_set)) + # Process Jira issues + jira_set.update(find_ji_in_line(line, 'JIRA')) + + return (log_entry, sorted(cve_set), sorted(bug_set), sorted(zbug_set), sorted(jira_set)) if __name__ == "__main__": all_bzs = [] all_zbzs = [] + all_jiras = [] commits = sys.stdin.read().split('\0') for c in commits: if not c: continue - log_item, cves, bugs, zbugs = parse_commit(c) + log_item, cves, bugs, zbugs, jiras = parse_commit(c) entry = f"{log_item}" - if bugs or zbugs: + if bugs or zbugs or jiras: entry += " [" if zbugs: entry += " ".join(zbugs) all_zbzs.extend(zbugs) - if bugs and zbugs: - entry += " " if bugs: + entry += " " if zbugs else "" entry += " ".join(bugs) all_bzs.extend(bugs) + if jiras: + entry += " " if bugs or zbugs else "" + entry += " ".join(jiras) + all_jiras.extend(jiras) entry += "]" if cves: entry += " {" + " ".join(cves) + "}" @@ -106,5 +120,9 @@ if __name__ == "__main__": if i: print(", ", end="") print(f"rhbz#{bzid}", end="") + for j, jid in enumerate(all_jiras): + if j or len(resolved_bzs) > 0: + print(", ", end="") + print(f"{jid}", end="") print("\n") -- https://gitlab.com/cki-project/kernel-ark/-/merge_requests/2496 _______________________________________________ kernel mailing list -- kernel@xxxxxxxxxxxxxxxxxxxxxxx To unsubscribe send an email to kernel-leave@xxxxxxxxxxxxxxxxxxxxxxx Fedora Code of Conduct: https://docs.fedoraproject.org/en-US/project/code-of-conduct/ List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines List Archives: https://lists.fedoraproject.org/archives/list/kernel@xxxxxxxxxxxxxxxxxxxxxxx Do not reply to spam, report it: https://pagure.io/fedora-infrastructure/new_issue