From f750d99676c9e412f461364d60926a88e3903042 Mon Sep 17 00:00:00 2001 From: Bruno Verachten Date: Tue, 10 Dec 2024 13:49:05 +0100 Subject: [PATCH 01/11] fix(fork): First try at the createFork method It takes the default_branch_only parameter into account. Tests still fail. --- .../java/org/kohsuke/github/GHRepository.java | 65 ++++++++++++------- .../org/kohsuke/github/GHRepositoryTest.java | 27 ++++++++ 2 files changed, 70 insertions(+), 22 deletions(-) diff --git a/src/main/java/org/kohsuke/github/GHRepository.java b/src/main/java/org/kohsuke/github/GHRepository.java index ab60eafb86..67e1874c05 100644 --- a/src/main/java/org/kohsuke/github/GHRepository.java +++ b/src/main/java/org/kohsuke/github/GHRepository.java @@ -1459,22 +1459,9 @@ public PagedIterable listForks(final ForkSort sort) { * @throws IOException * the io exception */ + @Deprecated public GHRepository fork() throws IOException { - root().createRequest().method("POST").withUrlPath(getApiTailUrl("forks")).send(); - - // 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"); + return createFork(null, null, false); } /** @@ -1504,16 +1491,50 @@ public GHBranchSync sync(String branch) throws IOException { * @throws IOException * the io exception */ + @Deprecated public GHRepository forkTo(GHOrganization org) throws IOException { - root().createRequest() - .method("POST") - .with("organization", org.getLogin()) - .withUrlPath(getApiTailUrl("forks")) - .send(); + return createFork(org.getLogin(), null, false); + } + + /** + * Creates a fork of this repository with optional parameters. + * + * @param organization + * the organization to fork to, or null to fork to the authenticated user's account + * @param name + * the name of the new repository, or null to use the same name as the original repository + * @param defaultBranchOnly + * whether to fork only the default branch + * @return the newly forked repository + * @throws IOException + * if an I/O error occurs + */ + public GHRepository createFork(String organization, String name, boolean defaultBranchOnly) throws IOException { + if (organization != null && organization.isEmpty()) { + throw new IllegalArgumentException("Organization cannot be empty"); + } + if (name != null && name.isEmpty()) { + throw new IllegalArgumentException("Name cannot be empty"); + } + + Requester requester = root().createRequest().method("POST").withUrlPath(getApiTailUrl("forks")); + + if (organization != null) { + requester.with("organization", organization); + } + if (name != null) { + requester.with("name", name); + } + if (defaultBranchOnly) { + requester.with("default_branch_only", true); + } + + requester.send(); // this API is asynchronous. we need to wait for a bit for (int i = 0; i < 10; i++) { - GHRepository r = org.getRepository(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; } @@ -1523,7 +1544,7 @@ public GHRepository forkTo(GHOrganization org) throws IOException { throw (IOException) new InterruptedIOException().initCause(e); } } - throw new IOException(this + " was forked into " + org.getLogin() + " but can't find the new repository"); + throw new IOException(this + " was forked but can't find the new repository"); } /** diff --git a/src/test/java/org/kohsuke/github/GHRepositoryTest.java b/src/test/java/org/kohsuke/github/GHRepositoryTest.java index 4a339571a3..38697ce8f6 100644 --- a/src/test/java/org/kohsuke/github/GHRepositoryTest.java +++ b/src/test/java/org/kohsuke/github/GHRepositoryTest.java @@ -823,6 +823,33 @@ public void ghRepositorySearchBuilderForkDefaultResetForksSearchTerms() { assertThat(ghRepositorySearchBuilder.terms.stream().filter(item -> item.contains("fork:")).count(), is(0L)); } + /** + * Test createFork method with valid parameters. + * + * @throws IOException + * Signals that an I/O exception has occurred. + */ + @Test + public void testCreateForkWithValidParameters() throws IOException { + GHRepository repository = getRepository(); + GHRepository forkedRepository = repository.createFork("new-owner", "new-repo", true); + assertThat(forkedRepository, notNullValue()); + assertThat(forkedRepository.getOwnerName(), equalTo("new-owner")); + assertThat(forkedRepository.getName(), equalTo("new-repo")); + } + + /** + * Test createFork method with invalid parameters. + * + * @throws IOException + * Signals that an I/O exception has occurred. + */ + @Test(expected = IllegalArgumentException.class) + public void testCreateForkWithInvalidParameters() throws IOException { + GHRepository repository = getRepository(); + repository.createFork(null, "", true); + } + /** * List commit comments some comments. * From f961ac3b281711853b11861952a9da75a4283eee Mon Sep 17 00:00:00 2001 From: gounthar Date: Tue, 10 Dec 2024 13:58:30 +0100 Subject: [PATCH 02/11] fix(fork): Add @deprecated Javadoc tag to deprecated method. --- src/main/java/org/kohsuke/github/GHRepository.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/org/kohsuke/github/GHRepository.java b/src/main/java/org/kohsuke/github/GHRepository.java index 67e1874c05..de8135d7a9 100644 --- a/src/main/java/org/kohsuke/github/GHRepository.java +++ b/src/main/java/org/kohsuke/github/GHRepository.java @@ -1458,6 +1458,7 @@ public PagedIterable listForks(final ForkSort sort) { * @return Newly forked repository that belong to you. * @throws IOException * the io exception + * @deprecated */ @Deprecated public GHRepository fork() throws IOException { @@ -1490,6 +1491,7 @@ public GHBranchSync sync(String branch) throws IOException { * @return Newly forked repository that belong to you. * @throws IOException * the io exception + * @deprecated */ @Deprecated public GHRepository forkTo(GHOrganization org) throws IOException { From ec415451c9da22da08a23c1bbdabcaa270f80348 Mon Sep 17 00:00:00 2001 From: Bruno Verachten Date: Tue, 10 Dec 2024 16:55:12 +0100 Subject: [PATCH 03/11] fix(fork): Test rewriting Still fails. --- src/main/java/org/kohsuke/github/GHRepository.java | 7 ++++--- .../java/org/kohsuke/github/GitHubWireMockRule.java | 10 ++++++++++ 2 files changed, 14 insertions(+), 3 deletions(-) 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"))); } /** From 97eabee2dc578a86ed4cd3904c99f6b57c75f3cc Mon Sep 17 00:00:00 2001 From: gounthar Date: Tue, 10 Dec 2024 17:00:10 +0100 Subject: [PATCH 04/11] fix(fork): Validate that name follows GitHub repository naming conventions and add @nullable annotations for optional parameters --- .../java/org/kohsuke/github/GHRepository.java | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/src/main/java/org/kohsuke/github/GHRepository.java b/src/main/java/org/kohsuke/github/GHRepository.java index f320d8f5a4..274d68b5e8 100644 --- a/src/main/java/org/kohsuke/github/GHRepository.java +++ b/src/main/java/org/kohsuke/github/GHRepository.java @@ -1501,24 +1501,23 @@ public GHRepository forkTo(GHOrganization org) throws IOException { /** * Creates a fork of this repository with optional parameters. * - * @param organization - * the organization to fork to, or null to fork to the authenticated user's account - * @param name - * the name of the new repository, or null to use the same name as the original repository - * @param defaultBranchOnly - * whether to fork only the default branch + * @param organization the organization to fork to, or null to fork to the authenticated user's account + * @param name the name of the new repository, or null to use the same name as the original repository + * @param defaultBranchOnly whether to fork only the default branch * @return the newly forked repository - * @throws IOException - * if an I/O error occurs + * @throws IOException if an I/O error occurs */ - public GHRepository createFork(String organization, String name, boolean defaultBranchOnly) throws IOException { + public GHRepository createFork(@Nullable String organization, @Nullable String name, boolean defaultBranchOnly) throws IOException { + if (organization != null && organization.isEmpty()) { throw new IllegalArgumentException("Organization cannot be empty"); } if (name != null && name.isEmpty()) { throw new IllegalArgumentException("Name cannot be empty"); } - + if (name != null && !name.matches("^[a-zA-Z0-9._-]+$")) { + throw new IllegalArgumentException("Repository name contains invalid characters"); + } Requester requester = root().createRequest().method("POST").withUrlPath(getApiTailUrl("forks")); if (organization != null) { From abfaa1cdd1fa8e528804b1c85d6b0e30adc58c34 Mon Sep 17 00:00:00 2001 From: gounthar Date: Tue, 10 Dec 2024 17:05:08 +0100 Subject: [PATCH 05/11] fix(fork): Add @deprecated reason and replacement information --- src/main/java/org/kohsuke/github/GHRepository.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/kohsuke/github/GHRepository.java b/src/main/java/org/kohsuke/github/GHRepository.java index 274d68b5e8..46601c6000 100644 --- a/src/main/java/org/kohsuke/github/GHRepository.java +++ b/src/main/java/org/kohsuke/github/GHRepository.java @@ -1458,9 +1458,9 @@ public PagedIterable listForks(final ForkSort sort) { * @return Newly forked repository that belong to you. * @throws IOException * the io exception - * @deprecated + * @deprecated Use {@link #createFork(String, String, boolean)} instead */ - @Deprecated + @Deprecated(forRemoval = true) public GHRepository fork() throws IOException { return createFork(null, null, false); } @@ -1491,9 +1491,9 @@ public GHBranchSync sync(String branch) throws IOException { * @return Newly forked repository that belong to you. * @throws IOException * the io exception - * @deprecated + * @deprecated Use {@link #createFork(String, String, boolean)} instead */ - @Deprecated + @Deprecated(forRemoval = true) public GHRepository forkTo(GHOrganization org) throws IOException { return createFork(org.getLogin(), null, false); } From f4b02f15d65ae224e05c32eddeb2e416fbd67443 Mon Sep 17 00:00:00 2001 From: gounthar Date: Tue, 10 Dec 2024 17:11:51 +0100 Subject: [PATCH 06/11] fix(fork): Typo --- src/main/java/org/kohsuke/github/GHRepository.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/kohsuke/github/GHRepository.java b/src/main/java/org/kohsuke/github/GHRepository.java index 46601c6000..887ad71418 100644 --- a/src/main/java/org/kohsuke/github/GHRepository.java +++ b/src/main/java/org/kohsuke/github/GHRepository.java @@ -1455,7 +1455,7 @@ public PagedIterable listForks(final ForkSort sort) { /** * Forks this repository as your repository. * - * @return Newly forked repository that belong to you. + * @return Newly forked repository that belongs to you. * @throws IOException * the io exception * @deprecated Use {@link #createFork(String, String, boolean)} instead @@ -1488,7 +1488,7 @@ public GHBranchSync sync(String branch) throws IOException { * * @param org * the org - * @return Newly forked repository that belong to you. + * @return Newly forked repository that belongs to you. * @throws IOException * the io exception * @deprecated Use {@link #createFork(String, String, boolean)} instead From fcb6a722e07c658b289a48e2928ced54a8869b92 Mon Sep 17 00:00:00 2001 From: gounthar Date: Tue, 10 Dec 2024 17:27:32 +0100 Subject: [PATCH 07/11] fix(fork): Spotless --- .../java/org/kohsuke/github/GHRepository.java | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/main/java/org/kohsuke/github/GHRepository.java b/src/main/java/org/kohsuke/github/GHRepository.java index 887ad71418..a4ce25d4a4 100644 --- a/src/main/java/org/kohsuke/github/GHRepository.java +++ b/src/main/java/org/kohsuke/github/GHRepository.java @@ -1501,13 +1501,18 @@ public GHRepository forkTo(GHOrganization org) throws IOException { /** * Creates a fork of this repository with optional parameters. * - * @param organization the organization to fork to, or null to fork to the authenticated user's account - * @param name the name of the new repository, or null to use the same name as the original repository - * @param defaultBranchOnly whether to fork only the default branch + * @param organization + * the organization to fork to, or null to fork to the authenticated user's account + * @param name + * the name of the new repository, or null to use the same name as the original repository + * @param defaultBranchOnly + * whether to fork only the default branch * @return the newly forked repository - * @throws IOException if an I/O error occurs + * @throws IOException + * if an I/O error occurs */ - public GHRepository createFork(@Nullable String organization, @Nullable String name, boolean defaultBranchOnly) throws IOException { + public GHRepository createFork(@Nullable String organization, @Nullable String name, boolean defaultBranchOnly) + throws IOException { if (organization != null && organization.isEmpty()) { throw new IllegalArgumentException("Organization cannot be empty"); From 618b36fa0aa3890691a70ebab429cd30cd80eb6f Mon Sep 17 00:00:00 2001 From: Bruno Verachten Date: Thu, 12 Dec 2024 12:10:55 +0100 Subject: [PATCH 08/11] Apply suggestions from code review Co-authored-by: Liam Newman --- .../java/org/kohsuke/github/GHRepository.java | 23 ++++++++++--------- .../kohsuke/github/GitHubWireMockRule.java | 10 -------- 2 files changed, 12 insertions(+), 21 deletions(-) diff --git a/src/main/java/org/kohsuke/github/GHRepository.java b/src/main/java/org/kohsuke/github/GHRepository.java index a4ce25d4a4..51fa2429e4 100644 --- a/src/main/java/org/kohsuke/github/GHRepository.java +++ b/src/main/java/org/kohsuke/github/GHRepository.java @@ -1515,22 +1515,18 @@ public GHRepository createFork(@Nullable String organization, @Nullable String n throws IOException { if (organization != null && organization.isEmpty()) { - throw new IllegalArgumentException("Organization cannot be empty"); + throw new IllegalArgumentException("Organization cannot be empty. Pass null for default value."); } if (name != null && name.isEmpty()) { - throw new IllegalArgumentException("Name cannot be empty"); + throw new IllegalArgumentException("Name cannot be empty. Pass null for default value."); } if (name != null && !name.matches("^[a-zA-Z0-9._-]+$")) { throw new IllegalArgumentException("Repository name contains invalid characters"); } Requester requester = root().createRequest().method("POST").withUrlPath(getApiTailUrl("forks")); - if (organization != null) { - requester.with("organization", organization); - } - if (name != null) { - requester.with("name", name); - } + requester.with("organization", organization); + requester.with("name", name); if (defaultBranchOnly) { requester.with("default_branch_only", true); } @@ -1539,9 +1535,14 @@ public GHRepository createFork(@Nullable String organization, @Nullable String n // 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) - : root().getMyself().getRepository(name != null ? name : this.name); + organization = organization != null ? organization : root().getMyself().getLogin(); + name = name != null ? name : this.name; + GHRepository r; + try { + r = GHRepository.read(root(), login, name); + } catch (FileNotFoundException e) { + r = null; + } 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 539d51526e..bd4224f9dc 100644 --- a/src/test/java/org/kohsuke/github/GitHubWireMockRule.java +++ b/src/test/java/org/kohsuke/github/GitHubWireMockRule.java @@ -241,16 +241,6 @@ 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"))); } /** From 3de300246d33841d6ce159b28912746b3ad5f411 Mon Sep 17 00:00:00 2001 From: gounthar Date: Thu, 12 Dec 2024 14:04:44 +0100 Subject: [PATCH 09/11] fix(fork): Add two createFork methods with less parameters. --- .../java/org/kohsuke/github/GHRepository.java | 23 ++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/kohsuke/github/GHRepository.java b/src/main/java/org/kohsuke/github/GHRepository.java index 51fa2429e4..a55ad588f4 100644 --- a/src/main/java/org/kohsuke/github/GHRepository.java +++ b/src/main/java/org/kohsuke/github/GHRepository.java @@ -1539,7 +1539,7 @@ public GHRepository createFork(@Nullable String organization, @Nullable String n name = name != null ? name : this.name; GHRepository r; try { - r = GHRepository.read(root(), login, name); + r = GHRepository.read(root(), root().getMyself().getLogin(), name); } catch (FileNotFoundException e) { r = null; } @@ -1555,6 +1555,27 @@ public GHRepository createFork(@Nullable String organization, @Nullable String n throw new IOException(this + " was forked but can't find the new repository"); } + /** + * Creates a fork of this repository. + * + * @param defaultBranchOnly if true, only the default branch will be forked + * @return the newly forked repository + * @throws IOException if an I/O error occurs + */ + public GHRepository createFork(boolean defaultBranchOnly) throws IOException { + return createFork(null, null, defaultBranchOnly); + } + + /** + * Creates a fork of this repository with the default branch only. + * + * @return the newly forked repository + * @throws IOException if an I/O error occurs + */ + public GHRepository createFork() throws IOException { + return createFork(true); + } + /** * Retrieves a specified pull request. * From 43730bfea44b8a303e682ef65b69e3dfe0046424 Mon Sep 17 00:00:00 2001 From: gounthar Date: Thu, 12 Dec 2024 14:37:44 +0100 Subject: [PATCH 10/11] fix(fork): Test rewriting --- src/test/java/org/kohsuke/github/GHRepositoryTest.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/test/java/org/kohsuke/github/GHRepositoryTest.java b/src/test/java/org/kohsuke/github/GHRepositoryTest.java index 38697ce8f6..5f54ee27e6 100644 --- a/src/test/java/org/kohsuke/github/GHRepositoryTest.java +++ b/src/test/java/org/kohsuke/github/GHRepositoryTest.java @@ -831,8 +831,10 @@ public void ghRepositorySearchBuilderForkDefaultResetForksSearchTerms() { */ @Test public void testCreateForkWithValidParameters() throws IOException { - GHRepository repository = getRepository(); - GHRepository forkedRepository = repository.createFork("new-owner", "new-repo", true); + String repositoryName = "rubywm"; + String upstreamRepositoryOrganization = "kohsuke"; + cleanupRepository(GITHUB_API_TEST_ORG + "/" + repositoryName); + GHRepository forkedRepository = gitHub.getRepository(upstreamRepositoryOrganization + "/" + repositoryName).createFork(gitHub.getOrganization(GITHUB_API_TEST_ORG).name, repositoryName, true); assertThat(forkedRepository, notNullValue()); assertThat(forkedRepository.getOwnerName(), equalTo("new-owner")); assertThat(forkedRepository.getName(), equalTo("new-repo")); From 86ca3f0e34bb4dddfcdfb0d45ce342ad5e2e2366 Mon Sep 17 00:00:00 2001 From: Bruno Verachten Date: Thu, 12 Dec 2024 14:57:07 +0100 Subject: [PATCH 11/11] fix(fork): Spotless-required changes. --- src/main/java/org/kohsuke/github/GHRepository.java | 11 +++++++---- .../java/org/kohsuke/github/GHRepositoryTest.java | 3 ++- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/main/java/org/kohsuke/github/GHRepository.java b/src/main/java/org/kohsuke/github/GHRepository.java index a55ad588f4..4859eac77d 100644 --- a/src/main/java/org/kohsuke/github/GHRepository.java +++ b/src/main/java/org/kohsuke/github/GHRepository.java @@ -1539,7 +1539,7 @@ public GHRepository createFork(@Nullable String organization, @Nullable String n name = name != null ? name : this.name; GHRepository r; try { - r = GHRepository.read(root(), root().getMyself().getLogin(), name); + r = GHRepository.read(root(), root().getMyself().getLogin(), name); } catch (FileNotFoundException e) { r = null; } @@ -1558,9 +1558,11 @@ public GHRepository createFork(@Nullable String organization, @Nullable String n /** * Creates a fork of this repository. * - * @param defaultBranchOnly if true, only the default branch will be forked + * @param defaultBranchOnly + * if true, only the default branch will be forked * @return the newly forked repository - * @throws IOException if an I/O error occurs + * @throws IOException + * if an I/O error occurs */ public GHRepository createFork(boolean defaultBranchOnly) throws IOException { return createFork(null, null, defaultBranchOnly); @@ -1570,7 +1572,8 @@ public GHRepository createFork(boolean defaultBranchOnly) throws IOException { * Creates a fork of this repository with the default branch only. * * @return the newly forked repository - * @throws IOException if an I/O error occurs + * @throws IOException + * if an I/O error occurs */ public GHRepository createFork() throws IOException { return createFork(true); diff --git a/src/test/java/org/kohsuke/github/GHRepositoryTest.java b/src/test/java/org/kohsuke/github/GHRepositoryTest.java index 5f54ee27e6..bc63b74e36 100644 --- a/src/test/java/org/kohsuke/github/GHRepositoryTest.java +++ b/src/test/java/org/kohsuke/github/GHRepositoryTest.java @@ -834,7 +834,8 @@ public void testCreateForkWithValidParameters() throws IOException { String repositoryName = "rubywm"; String upstreamRepositoryOrganization = "kohsuke"; cleanupRepository(GITHUB_API_TEST_ORG + "/" + repositoryName); - GHRepository forkedRepository = gitHub.getRepository(upstreamRepositoryOrganization + "/" + repositoryName).createFork(gitHub.getOrganization(GITHUB_API_TEST_ORG).name, repositoryName, true); + GHRepository forkedRepository = gitHub.getRepository(upstreamRepositoryOrganization + "/" + repositoryName) + .createFork(gitHub.getOrganization(GITHUB_API_TEST_ORG).name, repositoryName, true); assertThat(forkedRepository, notNullValue()); assertThat(forkedRepository.getOwnerName(), equalTo("new-owner")); assertThat(forkedRepository.getName(), equalTo("new-repo"));