Skip to content

Commit 5867c44

Browse files
author
Herton R. Krzesinski
committed
Merge: redhat: fix duplicate jira issues in the resolves line
MR: https://gitlab.com/redhat/centos-stream/src/kernel/centos-stream-9/-/merge_requests/2088 Bugzilla: INTERNAL Upstream Status: RHEL only Fix issue introduced by: a4f29a6 ("redhat: add support for Jira issues in changelog") Where if a merge request with a Jira issue attached has more than one commit, the generated changelog will list more than once the same jira issue in the resolves line (one for each commit listed). Signed-off-by: Herton R. Krzesinski <herton@redhat.com> Approved-by: Jarod Wilson <jarod@redhat.com> Approved-by: Jan Stancek <jstancek@redhat.com> Approved-by: Lucas Zampieri <lzampier@redhat.com> Signed-off-by: Herton R. Krzesinski <herton@redhat.com>
2 parents 53cdd29 + cb591aa commit 5867c44

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)