usethis icon indicating copy to clipboard operation
usethis copied to clipboard

`use_github()` fails with "Repo already exists" after renaming a repo

Open ateucher opened this issue 9 months ago • 0 comments

If I create a repo on GitHub, then rename it and then try to use use_github() with the old name, it errors with "Repo [reponame] already exists on 'github.com'", even though that name should be now be available after the renaming.

To reproduce:

On GitHub:

  1. Create a repo (called for example "test123")
  2. Rename the repo to "test123.old"

Locally:

  1. create_project("~/Desktop/test123")
  2. use_git() (accept all the prompts)
  3. use_github() - this gives:
    ℹ Defaulting to 'https' Git protocol
    ✔ Setting active project to '/Users/andy/dev/test123'
    Error: Repo 'ateucher/test123' already exists on 'github.com'
    

This occurs because of the redirect that GitHub does on renamed repos, so the API call in check_no_github_repo() here does not fail because it finds the renamed repo (test123.old).

ateucher avatar Sep 06 '23 19:09 ateucher