44from datetime import date
55from enum import Enum
66from math import log
7+ from os import getenv
78from pathlib import Path
89from pprint import pp
910from sys import exit
@@ -95,7 +96,7 @@ def relative_change(expected, actual):
9596def 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+
175197def 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