Skip to content

Commit cb591aa

Browse files
author
Herton R. Krzesinski
committed
redhat: fix duplicate jira issues in the resolves line
Bugzilla: INTERNAL Upstream Status: RHEL only The current genlog.py code does not check for duplicated jira issues added to the resolves line. For bugzilla numbers, that check was present when creating the resolved_bzs list. To resolve it, convert everything to sets (which can't have duplicated items), as such we don't need to do additional checks when printing the resolves line. Also, make sure we sort not only the per changelog item numbers, but also the items in the resolves line. Fixes: a4f29a6 ("redhat: add support for Jira issues in changelog") Signed-off-by: Herton R. Krzesinski <herton@redhat.com>
1 parent 50b1f6c commit cb591aa

File tree

1 file changed

+15
-18
lines changed

1 file changed

+15
-18
lines changed

redhat/genlog.py

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -80,13 +80,13 @@ def parse_commit(commit):
8080
# Process Jira issues
8181
jira_set.update(find_ji_in_line(line, 'JIRA'))
8282

83-
return (log_entry, sorted(cve_set), sorted(bug_set), sorted(zbug_set), sorted(jira_set))
83+
return (log_entry, cve_set, bug_set, zbug_set, jira_set)
8484

8585

8686
if __name__ == "__main__":
87-
all_bzs = []
88-
all_zbzs = []
89-
all_jiras = []
87+
all_bzs = set()
88+
all_zbzs = set()
89+
all_jiras = set()
9090
commits = sys.stdin.read().split('\0')
9191
for c in commits:
9292
if not c:
@@ -96,32 +96,29 @@ def parse_commit(commit):
9696
if bugs or zbugs or jiras:
9797
entry += " ["
9898
if zbugs:
99-
entry += " ".join(zbugs)
100-
all_zbzs.extend(zbugs)
99+
entry += " ".join(sorted(zbugs))
100+
all_zbzs.update(zbugs)
101101
if bugs:
102102
entry += " " if zbugs else ""
103-
entry += " ".join(bugs)
104-
all_bzs.extend(bugs)
103+
entry += " ".join(sorted(bugs))
104+
all_bzs.update(bugs)
105105
if jiras:
106106
entry += " " if bugs or zbugs else ""
107-
entry += " ".join(jiras)
108-
all_jiras.extend(jiras)
107+
entry += " ".join(sorted(jiras))
108+
all_jiras.update(jiras)
109109
entry += "]"
110110
if cves:
111-
entry += " {" + " ".join(cves) + "}"
111+
entry += " {" + " ".join(sorted(cves)) + "}"
112112
print(entry)
113113

114-
resolved_bzs = []
115-
for bzid in (all_zbzs if all_zbzs else all_bzs):
116-
if not bzid in resolved_bzs:
117-
resolved_bzs.append(bzid)
114+
resolved_bzs = all_zbzs if all_zbzs else all_bzs
118115
print("Resolves: ", end="")
119-
for i, bzid in enumerate(resolved_bzs):
116+
for i, bzid in enumerate(sorted(resolved_bzs)):
120117
if i:
121118
print(", ", end="")
122119
print(f"rhbz#{bzid}", end="")
123-
for j, jid in enumerate(all_jiras):
124-
if j or len(resolved_bzs) > 0:
120+
for j, jid in enumerate(sorted(all_jiras)):
121+
if j or resolved_bzs:
125122
print(", ", end="")
126123
print(f"{jid}", end="")
127124
print("\n")

0 commit comments

Comments
 (0)