@@ -32,6 +32,8 @@ class WorkflowError(RuntimeError):
3232@dataclass
3333class Summary :
3434 pr : int
35+ pr_url : str | None = None
36+ review_url : str | None = None
3537 original_branch : str = ""
3638 pr_branch : str = ""
3739 restored_branch : str | None = None
@@ -76,6 +78,12 @@ def print_text(self) -> None:
7678 print ("Notes:" )
7779 for note in self .notes :
7880 print (f"- { note } " )
81+ if self .pr_url or self .review_url :
82+ print ("Links:" )
83+ if self .pr_url :
84+ print (f"- PR: { self .pr_url } " )
85+ if self .review_url :
86+ print (f"- Review: { self .review_url } " )
7987
8088
8189def format_cmd (cmd : list [str ]) -> str :
@@ -190,10 +198,16 @@ def detect_repo(summary: Summary | None = None) -> str:
190198
191199
192200def pr_view (pr : int , summary : Summary ) -> dict [str , Any ]:
193- fields = "headRepositoryOwner,headRepository,headRefName,isCrossRepository,maintainerCanModify"
201+ fields = "headRepositoryOwner,headRepository,headRefName,isCrossRepository,maintainerCanModify,url "
194202 return gh_json (["pr" , "view" , str (pr ), "--json" , fields ], summary )
195203
196204
205+ def remember_pr_url (metadata : dict [str , Any ], summary : Summary ) -> None :
206+ url = metadata .get ("url" )
207+ if isinstance (url , str ) and url :
208+ summary .pr_url = url
209+
210+
197211def authed_login (summary : Summary ) -> str :
198212 return gh (["api" , "user" , "--jq" , ".login" ], summary ).stdout .strip ()
199213
@@ -214,13 +228,16 @@ def checkout_pr(pr: int, summary: Summary) -> dict[str, Any]:
214228 progress (f"Checking out PR #{ pr } " )
215229 gh (["pr" , "checkout" , str (pr )], summary )
216230 summary .pr_branch = current_branch (summary )
217- return ensure_pr_push_allowed (pr , summary )
231+ metadata = ensure_pr_push_allowed (pr , summary )
232+ remember_pr_url (metadata , summary )
233+ return metadata
218234
219235
220236def checkout_pr_no_push_check (pr : int , summary : Summary ) -> None :
221237 progress (f"Checking out PR #{ pr } " )
222238 gh (["pr" , "checkout" , str (pr )], summary )
223239 summary .pr_branch = current_branch (summary )
240+ remember_pr_url (pr_view (pr , summary ), summary )
224241
225242
226243def run_pr_workflow (pr : int , body : Callable [[Summary ], int ], * , push_required : bool = True ) -> int :
0 commit comments