@@ -148,12 +148,13 @@ async def sync_pr(pull_request, gh, gl, gl_user, src_repo_private):
148148
149149 src_repo_url = pull_request ["head" ]["repo" ]["clone_url" ]
150150 src_fullname = pull_request ["head" ]["repo" ]["full_name" ]
151+ base_fullname = pull_request ["base" ]["repo" ]["full_name" ]
151152 want_sha = pull_request ["head" ]["sha" ]
152153
153154 # pull requests coming from forks are pushed as branches in the form of
154155 # pr-<pr-number> instead of as their branch name as conflicts could occur
155156 # between multiple repositories
156- is_pull_request_fork = src_fullname != pull_request [ "base" ][ "repo" ][ "full_name" ]
157+ is_pull_request_fork = src_fullname != base_fullname
157158 if is_pull_request_fork :
158159 target_ref = f"refs/heads/pr-{ pull_request_id } "
159160 else :
@@ -172,7 +173,7 @@ async def sync_pr(pull_request, gh, gl, gl_user, src_repo_private):
172173 return
173174
174175 # get the repository configuration from .github/hubcast.yml
175- repo_config = await get_repo_config (gh , src_fullname )
176+ repo_config = await get_repo_config (gh , base_fullname )
176177 if not repo_config .draft_sync and pull_request ["draft" ]:
177178 if repo_config .draft_sync_msg :
178179 await gh .set_check_status (
@@ -252,21 +253,22 @@ async def sync_pr_event(event, gh, gl, gl_user, *arg, **kwargs):
252253async def remove_pr (event , gh , gl , gl_user , * arg , ** kwargs ):
253254 pull_request = event .data ["pull_request" ]
254255 src_fullname = pull_request ["head" ]["repo" ]["full_name" ]
256+ base_fullname = pull_request ["base" ]["repo" ]["full_name" ]
255257
256258 # if the pull request comes from a fork we should clean up
257259 # the branch upon closing or merging the PR. However, if the
258260 # pull request comes from an internal branch we should wait
259261 # to clean up the branch when the branch is deleted from the
260262 # internal repository
261- is_pull_request_fork = src_fullname != pull_request [ "base" ][ "repo" ][ "full_name" ]
263+ is_pull_request_fork = src_fullname != base_fullname
262264 if not is_pull_request_fork :
263265 return
264266
265267 pull_request_id = pull_request ["number" ]
266268 target_ref = f"refs/heads/pr-{ pull_request_id } "
267269
268270 # get the repository configuration from .github/hubcast.yml
269- repo_config = await get_repo_config (gh , src_fullname )
271+ repo_config = await get_repo_config (gh , base_fullname )
270272
271273 dest_fullname = f"{ repo_config .dest_org } /{ repo_config .dest_name } "
272274 dest_remote_url = f"{ gl .instance_url } /{ dest_fullname } .git"
@@ -328,17 +330,18 @@ async def respond_comment(event, gh, gl, gl_user, *arg, **kwargs):
328330
329331 # get the branch this PR belongs to
330332 src_fullname = pull_request ["head" ]["repo" ]["full_name" ]
333+ base_fullname = pull_request ["base" ]["repo" ]["full_name" ]
331334 # pull requests coming from forks are pushed as branches in the form of
332335 # pr-<pr-number> instead of as their branch name as conflicts could occur
333336 # between multiple repositories
334- is_pull_request_fork = src_fullname != pull_request [ "base" ][ "repo" ][ "full_name" ]
337+ is_pull_request_fork = src_fullname != base_fullname
335338 if is_pull_request_fork :
336339 branch = f"pr-{ pull_request_id } "
337340 else :
338341 branch = pull_request ["head" ]["ref" ]
339342
340343 # get the gitlab repo information and run the pipeline
341- repo_config = await get_repo_config (gh , src_fullname , refresh = True )
344+ repo_config = await get_repo_config (gh , base_fullname , refresh = True )
342345 dest_fullname = f"{ repo_config .dest_org } /{ repo_config .dest_name } "
343346 pipeline_url = await gl .run_pipeline (dest_fullname , branch )
344347
@@ -359,17 +362,18 @@ async def respond_comment(event, gh, gl, gl_user, *arg, **kwargs):
359362
360363 # get the branch this PR belongs to
361364 src_fullname = pull_request ["head" ]["repo" ]["full_name" ]
365+ base_fullname = pull_request ["base" ]["repo" ]["full_name" ]
362366 # pull requests coming from forks are pushed as branches in the form of
363367 # pr-<pr-number> instead of as their branch name as conflicts could occur
364368 # between multiple repositories
365- is_pull_request_fork = src_fullname != pull_request [ "base" ][ "repo" ][ "full_name" ]
369+ is_pull_request_fork = src_fullname != base_fullname
366370 if is_pull_request_fork :
367371 branch = f"pr-{ pull_request_id } "
368372 else :
369373 branch = pull_request ["head" ]["ref" ]
370374
371375 # get the gitlab repo information and run the pipeline
372- repo_config = await get_repo_config (gh , src_fullname , refresh = True )
376+ repo_config = await get_repo_config (gh , base_fullname , refresh = True )
373377 dest_fullname = f"{ repo_config .dest_org } /{ repo_config .dest_name } "
374378 pipeline_id = await gl .get_latest_pipeline (dest_fullname , branch )
375379
0 commit comments