Skip to content

Commit d9bc242

Browse files
Merge pull request #809 from Horki/767_pr_title
767: triage; fetch pr titles
2 parents d575fba + 6e8f5b2 commit d9bc242

File tree

1 file changed

+25
-2
lines changed

1 file changed

+25
-2
lines changed

triage/weekly_report.py

+25-2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from datetime import date
55
from enum import Enum
66
from math import log
7+
from os import getenv
78
from pathlib import Path
89
from pprint import pp
910
from sys import exit
@@ -95,7 +96,7 @@ def relative_change(expected, actual):
9596
def log_change(expected, actual):
9697
'''Returns `ln(actual / expected)`
9798
98-
This is prefereable to percentage change because it scales equally for
99+
This is preferable to percentage change because it scales equally for
99100
positive or negative changes. This means that the order of the arguments
100101
only affects the sign of the output
101102
@@ -172,6 +173,27 @@ def gh_link(pr):
172173
return f'https://github.com/rust-lang/rust/issues/{pr}'
173174

174175

176+
def gh_pr_title(pr):
177+
def make_req():
178+
url = f'https://api.github.com/repos/rust-lang/rust/pulls/{pr}'
179+
req = urllib.request.Request(url)
180+
req.add_header('Content-Type', 'application/json')
181+
if getenv("GITHUB_TOKEN") is not None:
182+
req.add_header('Authorization', f'token {getenv("GITHUB_TOKEN")}')
183+
184+
with urllib.request.urlopen(req) as f:
185+
data = json.loads(f.read())
186+
return data.get('title', '')
187+
188+
result = ''
189+
try:
190+
result = make_req()
191+
except urllib.error.HTTPError as e:
192+
eprint(e)
193+
finally:
194+
return result
195+
196+
175197
def compare_link(start, end, stat):
176198
return f'https://perf.rust-lang.org/compare.html?start={start}&end={end}&stat={stat.value}'
177199

@@ -180,8 +202,9 @@ def write_section(res, *changes):
180202
pr = res['b']['pr']
181203
start = res['a']['commit']
182204
end = res['b']['commit']
205+
title = gh_pr_title(pr)
183206

184-
msg = f'[#{pr}]({gh_link(pr)})'
207+
msg = f'{title}[#{pr}]({gh_link(pr)})'
185208

186209
for change in changes:
187210
msg += '\n- '

0 commit comments

Comments
 (0)