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

GHORG_FETCH_ALL is incompatible with cloning via fine-grained token over https #483

Open
brainplot opened this issue Jan 7, 2025 · 1 comment

Comments

@brainplot
Copy link

brainplot commented Jan 7, 2025

Describe the bug
I couldn't figure out why ghorg would clone just fine a few public repos from a GitHub org I'm trying to backup but then as soon as it got to a private repo, I was presented with the interactive prompt that git typically shows when it needs credentials:

Username for `https://github.com`:
Password for `https://github.com`:

The cloning would, as a result, get stuck there until I filled in my credentials.

I immediately thought of some issue with the token I had set in the config file so I went to test it manually but it worked just fine. Also, to my surprise, inspecting the output folder showed that the private repos had successfully been cloned. Running the command again with GHORG_DEBUG=1 and --concurency=1 showed me what the exact problem was:

I had modified the sample config file provided in the README.md and I had set GHORG_FETCH_ALL: true. This option clones the repository correctly using the https://<username>:<token>@github.com/<org>/<repo>.git URL but then it manually updates the remote's URL with the git set-url command leaving out the token (e.g. https://github.com/<org>/<repo>.git).

Subsequently, when git fetch --all runs it tries to fetch all branches using the plain URL (without the token) and that's why I get the login prompt.

In my opinion, when trying to clone using a token via https, GHORG_FETCH_ALL should either have no effect or ghorg should exit immediately with an error.

P.S. eventually I found out what I was actually looking for was just GHORG_BACKUP but that's beside the point so I got my backup working in the end but I still wanted to report this for posterity :)

@gabrie30
Copy link
Owner

gabrie30 commented Jan 8, 2025

Thank you for raising this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants