Skip to content

Commit

Permalink
Make name of forked repos include the original user
Browse files Browse the repository at this point in the history
  • Loading branch information
grst committed Aug 4, 2023
1 parent 8875ce7 commit b89738e
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions scripts/src/scverse_template_scripts/cruft_prs.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,10 +189,13 @@ def cruft_update(con: GitHubConnection, tag_name: str, repo: GHRepo, path: Path,
return True


def get_fork(con: GitHubConnection, repo: GHRepo) -> GHRepo:
if fork := next((f for f in repo.get_forks() if f.owner.id == con.user.id), None):
def get_fork(con: GitHubConnection, repo: GHRepo, name: str) -> GHRepo:
if fork := next(
(f for f in repo.get_forks() if f.owner.id == con.user.id and f.name == name),
None,
):
return fork
fork = repo.create_fork()
fork = repo.create_fork(name=name)
return retry_with_backoff(
lambda: con.gh.get_repo(fork.id),
retries=n_retries,
Expand All @@ -207,7 +210,7 @@ def make_pr(con: GitHubConnection, release: GHRelease, repo_url: str) -> None:

# create fork, populate branch, do PR from it
origin = con.gh.get_repo(repo_url.removeprefix("https://github.com/"))
repo = get_fork(con, origin)
repo = get_fork(con, origin, pr.repo_id)
with TemporaryDirectory() as td:
updated = cruft_update(con, release.tag_name, repo, Path(td), pr)
if updated:
Expand Down

0 comments on commit b89738e

Please sign in to comment.