Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
ateucher opened this issue Sep 6, 2023 · 1 comment · Fixed by #1894
Closed

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

ateucher opened this issue Sep 6, 2023 · 1 comment · Fixed by #1894
Labels
bug an unexpected problem or unintended behavior git git, GitHub, and CI in general

Comments

@ateucher
Copy link
Collaborator

ateucher commented Sep 6, 2023

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).

@hadley hadley added bug an unexpected problem or unintended behavior git git, GitHub, and CI in general labels Nov 3, 2023
@jennybc
Copy link
Member

jennybc commented Jul 23, 2024

Returning here at long last!

Taking some notes: this gives me some hope that perhaps we can learn that there's been a redirect?

https://gist.github.com/jasonrudolph/56388a4ff51b4f721cac

But we're pretty far from making a curl request ourselves. Both gh and httr2 sit between us and the GitHub API and I think they are helpfully shielding us from the 301.

Update: I don't think it would be worth it (or even possible) to detect the redirect directly in usethis. I can believe the method used in #1894 is the most practical.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug an unexpected problem or unintended behavior git git, GitHub, and CI in general
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants