4
4
from datetime import date
5
5
from enum import Enum
6
6
from math import log
7
+ from os import getenv
7
8
from pathlib import Path
8
9
from pprint import pp
9
10
from sys import exit
@@ -95,7 +96,7 @@ def relative_change(expected, actual):
95
96
def log_change (expected , actual ):
96
97
'''Returns `ln(actual / expected)`
97
98
98
- This is prefereable to percentage change because it scales equally for
99
+ This is preferable to percentage change because it scales equally for
99
100
positive or negative changes. This means that the order of the arguments
100
101
only affects the sign of the output
101
102
@@ -172,6 +173,27 @@ def gh_link(pr):
172
173
return f'https://github.com/rust-lang/rust/issues/{ pr } '
173
174
174
175
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
+
175
197
def compare_link (start , end , stat ):
176
198
return f'https://perf.rust-lang.org/compare.html?start={ start } &end={ end } &stat={ stat .value } '
177
199
@@ -180,8 +202,9 @@ def write_section(res, *changes):
180
202
pr = res ['b' ]['pr' ]
181
203
start = res ['a' ]['commit' ]
182
204
end = res ['b' ]['commit' ]
205
+ title = gh_pr_title (pr )
183
206
184
- msg = f'[#{ pr } ]({ gh_link (pr )} )'
207
+ msg = f'{ title } [#{ pr } ]({ gh_link (pr )} )'
185
208
186
209
for change in changes :
187
210
msg += '\n - '
0 commit comments