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

Already on GitHub? Sign in to your account

`hub fork` tries to fetch the new fork before it exists #301

Closed
indirect opened this Issue Mar 19, 2013 · 7 comments

Comments

Projects
None yet
5 participants

I ran git fork, and it failed trying to fetch from my fork. When I ran git remote update immediately afterwards, it worked. Maybe hub just needs to wait a second before fetching?

andre ~/sw/gems/html-pipeline master $ git fork
Updating indirect
fatal: https://github.com/indirect/html-pipeline.git/info/refs?service=git-upload-pack not found: did you run git update-server-info on the server?
error: Could not fetch indirect
andre ~/sw/gems/html-pipeline master $ git fork
fatal: remote indirect already exists.
andre ~/sw/gems/html-pipeline master $ git remote update
Fetching origin
Fetching indirect
From https://github.com/indirect/html-pipeline
 * [new branch]      context_validation -> indirect/context_validation
 * [new branch]      fix-deps   -> indirect/fix-deps
 * [new branch]      history    -> indirect/history
 * [new branch]      master     -> indirect/master
 * [new branch]      opensource -> indirect/opensource
 * [new branch]      pipeline-build -> indirect/pipeline-build
 * [new branch]      remove-git-from-gemspec -> indirect/remove-git-from-gemspec
 * [new branch]      required-contexts -> indirect/required-contexts
 * [new branch]      security-li-xss -> indirect/security-li-xss
Member

mislav commented Mar 19, 2013

I never had a problem with timing, but maybe you're right. hub does try to fetch from the new repo just moments after creating it, and that may be too fast. The trouble is, I don't know how long should I wait. Also, if I add a sleep statement, the command will feel slow.

Totally understood. Could it maybe just retry once after a sleep 1 if it fails the first time? I think that would fix it.

deiga commented Mar 19, 2013

+1
I get this issue with my forks too, would be great to have a short sleep etc. (Maybe write in the output that it's waiting for github to create the fork?)

kiike commented Apr 23, 2013

Or maybe just check a couple times if the fork is ready and proceed instead of a sleep command?

Contributor

ivantsepp commented Jan 22, 2014

Since creating a fork via the API is asynchronous, there is really no way of knowing when you can access the git objects. So,

  1. Does hub need to fetch from the new repo? Hub uses git remote add -f .... Is it okay to only do a git remote add ...?

  2. Can hub get away with adding a remote with the 'origin' url and fetch that. Then, use git remote set-url ... to change it to the fork's url. This creates the illusion of fetching from your fork (assuming forks are exactly the same as the 'origin'). However, this results in git output like:

    Updating ivantsepp
    From git://github.com/jch/html-pipeline
    

Just some alternative ideas to polling Github to check if fork is created.

Member

mislav commented Jan 22, 2014

Both your points are really great points. I guess I wanted to fetch from the new fork just to establish the current state and have remote tracking branches (yourname/master, ...) be created in your local repo. If I didn't fetch from the repo, will you still able to push to a branch in your fork? This is what I'm most concerned with. I will have to test that.

Your suggestion under "2" is even better. Want to code that up and submit a PR?

Member

mislav commented Jan 23, 2014

Fixed in 7672e14, thanks @ivantsepp!

@mislav mislav closed this Jan 23, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment