From a1e171139a7f8f2925ac3d2d05cae5fed8fb5b74 Mon Sep 17 00:00:00 2001 From: Gregor Sturm Date: Mon, 30 Mar 2026 20:28:25 +0200 Subject: [PATCH] Take up template sync where it got interrupted --- .../src/scverse_template_scripts/cruft_prs.py | 40 ++++++++++--------- 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/scripts/src/scverse_template_scripts/cruft_prs.py b/scripts/src/scverse_template_scripts/cruft_prs.py index 5950e421..7fac0b06 100644 --- a/scripts/src/scverse_template_scripts/cruft_prs.py +++ b/scripts/src/scverse_template_scripts/cruft_prs.py @@ -501,7 +501,7 @@ def make_pr(con: GitHubConnection, release: GHRelease, repo_url: str, *, log_dir forked_repo = get_fork(con, original_repo) - updated = template_update( + template_update( con, forked_repo=forked_repo, original_repo=original_repo, @@ -514,24 +514,26 @@ def make_pr(con: GitHubConnection, release: GHRelease, repo_url: str, *, log_dir if dry_run: log.info("Skipping PR because in dry-run mode") return - if updated: - if old_pr := next((p for p in original_repo.get_pulls("open") if pr.matches_current_version(p)), None): - log.info(f"PR already exists: #{old_pr.number} with branch name `{old_pr.head.ref}`. Skipping PR creation.") - return - - if old_pr := next((p for p in original_repo.get_pulls("open") if pr.matches_prefix(p)), None): - log.info(f"Closing old PR #{old_pr.number} with branch name `{old_pr.head.ref}`.") - old_pr.edit(state="closed") - - log.info(f"Creating PR of {pr.namespaced_head} against {original_repo.default_branch}") - new_pr = original_repo.create_pull( - title=pr.title, - body=pr.body, - base=original_repo.default_branch, - head=pr.namespaced_head, - maintainer_can_modify=True, - ) - log.info(f"Created PR #{new_pr.number} with branch name `{new_pr.head.ref}`.") + + # check against all PRs, including closed ones -- if one already exists for the current version, + # and the developer closed it, we do not want to reopen it. + if old_pr := next((p for p in original_repo.get_pulls() if pr.matches_current_version(p)), None): + log.info(f"PR already exists: #{old_pr.number} with branch name `{old_pr.head.ref}`. Skipping PR creation.") + return + + if old_pr := next((p for p in original_repo.get_pulls("open") if pr.matches_prefix(p)), None): + log.info(f"Closing old PR #{old_pr.number} with branch name `{old_pr.head.ref}`.") + old_pr.edit(state="closed") + + log.info(f"Creating PR of {pr.namespaced_head} against {original_repo.default_branch}") + new_pr = original_repo.create_pull( + title=pr.title, + body=pr.body, + base=original_repo.default_branch, + head=pr.namespaced_head, + maintainer_can_modify=True, + ) + log.info(f"Created PR #{new_pr.number} with branch name `{new_pr.head.ref}`.") cli = App()