Skip to content

Commit 7885071

Browse files
committed
add a maintainer column
Signed-off-by: Gaëtan Lehmann <gaetan.lehmann@vates.tech>
1 parent c258a97 commit 7885071

File tree

1 file changed

+21
-5
lines changed

1 file changed

+21
-5
lines changed

scripts/pkg_in_pipe/pkg_in_pipe.py

+21-5
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,14 @@
22

33
import argparse
44
import io
5+
import json
56
import os
67
import re
78
import sys
89
from datetime import datetime
910
from textwrap import dedent
1011
from typing import cast
12+
from urllib.request import urlopen
1113

1214
import diskcache
1315
import github
@@ -88,7 +90,10 @@ def print_table_header(out, tag):
8890
Pull Requests
8991
</th>
9092
<th scope="col" class="px-6 py-3">
91-
By
93+
Built by
94+
</th>
95+
<th scope="col" class="px-6 py-3">
96+
Maintained by
9297
</th>
9398
</tr>
9499
</thead>
@@ -103,7 +108,7 @@ def print_table_footer(out):
103108
</div>
104109
'''), file=out)
105110

106-
def print_table_line(out, build, link, issues, by, prs: list[PullRequest]):
111+
def print_table_line(out, build, link, issues, built_by, prs: list[PullRequest], maintained_by):
107112
issues_content = '\n'.join([
108113
f'''<li>
109114
<a class="font-medium text-blue-600 dark:text-blue-500 hover:underline"
@@ -136,7 +141,10 @@ def print_table_line(out, build, link, issues, by, prs: list[PullRequest]):
136141
</ul>
137142
</td>
138143
<td class="px-6 py-4">
139-
{by}
144+
{built_by}
145+
</td>
146+
<td class="px-6 py-4">
147+
{maintained_by if maintained_by is not None else ''}
140148
</td>
141149
</tr>
142150
''', file=out) # nopep8
@@ -231,6 +239,10 @@ def find_pull_requests(gh, repo, start_sha, end_sha):
231239
else:
232240
gh = None
233241

242+
# load the packages maintainers
243+
with urlopen('https://github.com/xcp-ng/xcp/raw/refs/heads/master/scripts/rpm_owners/packages.json') as f:
244+
PACKAGES = json.load(f)
245+
234246
ok = True
235247
with open(args.output, 'w') as out:
236248
print_header(out)
@@ -250,13 +262,17 @@ def find_pull_requests(gh, repo, start_sha, end_sha):
250262
for tagged in sorted(session.listTagged(tag), key=lambda build: int(build['build_id']), reverse=True):
251263
build = session.getBuild(tagged['build_id'])
252264
prs: list[PullRequest] = []
265+
maintained_by = None
253266
previous_build_sha = find_previous_build_commit(session, tag, build)
254267
if gh and build['source'] is not None:
255268
(repo, sha) = parse_source(build['source'])
256269
prs = find_pull_requests(gh, repo, sha, previous_build_sha)
257-
build_url = f'https://koji.xcp-ng.org/buildinfo?buildID={tagged['build_id']}'
270+
maintained_by = PACKAGES.get(repo.split('/')[-1], {}).get('maintainer')
271+
build_url = f'https://koji.xcp-ng.org/buildinfo?buildID={tagged["build_id"]}'
258272
build_issues = filter_issues(issues, [build_url] + [pr.html_url for pr in prs])
259-
print_table_line(temp_out, tagged['nvr'], build_url, build_issues, tagged['owner_name'], prs)
273+
print_table_line(
274+
temp_out, tagged['nvr'], build_url, build_issues, tagged['owner_name'], prs, maintained_by
275+
)
260276
print_table_footer(temp_out)
261277
out.write(temp_out.getvalue())
262278
except Exception as e:

0 commit comments

Comments
 (0)