Skip to content

Commit 8634d95

Browse files
committed
Close PRs for which there is no latest_series on sync
After recent fixes in subject-branch mapping, when syncing "old" subjects a situation may occur when there are no relevant series for an open PR. This caused the following error message: ``` E0807 21:21:26.207 branch_worker.py:863] BUG: Unable to find PR for selftests/bpf: Install test modules into $INSTALL_PATH https://patchwork.kernel.org/project/netdevbpf/list/?series=985731 ``` Fix it by explicitly checking for latest_series() and closing the PR if it doesn't exist. Differential Revision: D79864591 Reviewed-by: Amery Hung <[email protected]> Signed-off-by: Ihor Solodrai <[email protected]>
1 parent ab7bee7 commit 8634d95

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

kernel_patches_daemon/github_sync.py

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -336,21 +336,35 @@ async def sync_patches(self) -> None:
336336
parsed_ref = parse_pr_ref(pr.head.ref)
337337
# ignore unknown format branch/PRs.
338338
if not parsed_pr_ref_ok(parsed_ref):
339-
logger.warning(
339+
logger.info(
340340
f"Unexpected format of the branch name: {pr.head.ref}"
341341
)
342342
continue
343343

344+
if parsed_ref["target"] != worker.repo_branch:
345+
logger.info(
346+
f"Skipping sync of PR {pr.number} ({pr.head.ref}) as it's not for {worker.repo_branch}"
347+
)
348+
continue
349+
344350
series_id = parsed_ref["series_id"]
345351
series = await self.pw.get_series_by_id(series_id)
346352
subject = self.pw.get_subject_by_series(series)
347353
if subject_name != subject.subject:
348-
logger.warning(
354+
logger.info(
349355
f"Renaming {pr} from {subject_name} to {subject.subject} according to {series.id}"
350356
)
351357
pr.edit(title=subject.subject)
358+
359+
latest_series = await subject.latest_series()
360+
if latest_series is None:
361+
logger.warning(
362+
f"Closing {pr} associated with irrelevent or outdated series {series_id}"
363+
)
364+
pr.edit(state="close")
365+
continue
366+
352367
branch_name = await worker.subject_to_branch(subject)
353-
latest_series = await subject.latest_series() or series
354368
pr = await self.checkout_and_patch_safe(
355369
worker, branch_name, latest_series
356370
)

0 commit comments

Comments
 (0)