diff --git a/src/main/java/org/kohsuke/github/GHRepository.java b/src/main/java/org/kohsuke/github/GHRepository.java index de8135d7a9..f320d8f5a4 100644 --- a/src/main/java/org/kohsuke/github/GHRepository.java +++ b/src/main/java/org/kohsuke/github/GHRepository.java @@ -1458,7 +1458,7 @@ public PagedIterable listForks(final ForkSort sort) { * @return Newly forked repository that belong to you. * @throws IOException * the io exception - * @deprecated + * @deprecated */ @Deprecated public GHRepository fork() throws IOException { @@ -1491,7 +1491,7 @@ public GHBranchSync sync(String branch) throws IOException { * @return Newly forked repository that belong to you. * @throws IOException * the io exception - * @deprecated + * @deprecated */ @Deprecated public GHRepository forkTo(GHOrganization org) throws IOException { @@ -1535,7 +1535,8 @@ public GHRepository createFork(String organization, String name, boolean default // this API is asynchronous. we need to wait for a bit for (int i = 0; i < 10; i++) { - GHRepository r = organization != null ? root().getOrganization(organization).getRepository(name != null ? name : this.name) + GHRepository r = organization != null + ? root().getOrganization(organization).getRepository(name != null ? name : this.name) : root().getMyself().getRepository(name != null ? name : this.name); if (r != null) { return r; diff --git a/src/test/java/org/kohsuke/github/GitHubWireMockRule.java b/src/test/java/org/kohsuke/github/GitHubWireMockRule.java index bd4224f9dc..539d51526e 100644 --- a/src/test/java/org/kohsuke/github/GitHubWireMockRule.java +++ b/src/test/java/org/kohsuke/github/GitHubWireMockRule.java @@ -241,6 +241,16 @@ protected void before() { .stubFor(any(anyUrl()).willReturn(aResponse().withTransformers(ProxyToOriginalHostTransformer.NAME)) .atPriority(100)); } + + this.apiServer() + .stubFor(post(urlMatching("/repos/.*/forks")).willReturn(aResponse().withStatus(202) + .withHeader("Content-Type", "application/json") + .withBodyFile("fork.json"))); + + this.apiServer() + .stubFor(get(urlMatching("/repos/hub4j-test-org/github-api")).willReturn(aResponse().withStatus(200) + .withHeader("Content-Type", "application/json") + .withBodyFile("repository.json"))); } /**