Skip to content

Commit

Permalink
Issue #264: wait for the repo to finish forking
Browse files Browse the repository at this point in the history
  • Loading branch information
kohsuke committed Jun 3, 2016
1 parent 27e855d commit 1bfe7dd
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/main/java/org/kohsuke/github/GHRepository.java
Original file line number Diff line number Diff line change
Expand Up @@ -587,7 +587,19 @@ protected void wrapUp(GHRepository[] page) {
* Newly forked repository that belong to you.
*/
public GHRepository fork() throws IOException {
return new Requester(root).method("POST").to(getApiTailUrl("forks"), GHRepository.class).wrap(root);
new Requester(root).method("POST").to(getApiTailUrl("forks"), null);

// this API is asynchronous. we need to wait for a bit
for (int i=0; i<10; i++) {
GHRepository r = root.getMyself().getRepository(name);
if (r!=null) return r;
try {
Thread.sleep(3000);
} catch (InterruptedException e) {
throw (IOException)new InterruptedIOException().initCause(e);
}
}
throw new IOException(this+" was forked but can't find the new repository");
}

/**
Expand Down

0 comments on commit 1bfe7dd

Please sign in to comment.