1414
1515
1616# Regex to match ghstack branch names: gh/{username}/{number}/{kind}
17- RE_GHSTACK_BRANCH = re .compile (r"^(?:refs/(?:heads|remotes/[^/]+)/)?gh/([^/]+)/([0-9]+)/(.+)$" )
17+ RE_GHSTACK_BRANCH = re .compile (
18+ r"^(?:refs/(?:heads|remotes/[^/]+)/)?gh/([^/]+)/([0-9]+)/(.+)$"
19+ )
1820
1921
2022def parse_ghstack_branch (ref : str ) -> Optional [Tuple [str , GhNumber , str ]]:
@@ -257,10 +259,14 @@ def main(
257259 pr_number , is_closed = pr_info
258260 pr_closed_cache [pr_number ] = is_closed
259261 if is_closed :
260- logging .info (f"PR #{ pr_number } (gh/{ branch_username } /{ ghnum } ) is closed" )
262+ logging .info (
263+ f"PR #{ pr_number } (gh/{ branch_username } /{ ghnum } ) is closed"
264+ )
261265 orphan_branches .extend (branches )
262266 else :
263- logging .debug (f"PR #{ pr_number } (gh/{ branch_username } /{ ghnum } ) is still open" )
267+ logging .debug (
268+ f"PR #{ pr_number } (gh/{ branch_username } /{ ghnum } ) is still open"
269+ )
264270 continue
265271
266272 # Check cache first (handles multiple ghnums mapping to same PR)
@@ -275,7 +281,9 @@ def main(
275281 logging .info (f"PR #{ pr_number } (gh/{ branch_username } /{ ghnum } ) is closed" )
276282 orphan_branches .extend (branches )
277283 else :
278- logging .debug (f"PR #{ pr_number } (gh/{ branch_username } /{ ghnum } ) is still open" )
284+ logging .debug (
285+ f"PR #{ pr_number } (gh/{ branch_username } /{ ghnum } ) is still open"
286+ )
279287
280288 if not orphan_branches :
281289 logging .info ("No orphan branches found." )
@@ -317,7 +325,7 @@ def main(
317325 deleted_branches : List [str ] = []
318326
319327 for i in range (0 , len (orphan_branches ), batch_size ):
320- batch = orphan_branches [i : i + batch_size ]
328+ batch = orphan_branches [i : i + batch_size ]
321329 try :
322330 sh .git ("push" , remote_name , "--delete" , * batch )
323331 deleted_branches .extend (batch )
0 commit comments