diff --git a/src/main/java/org/kohsuke/github/GHRepository.java b/src/main/java/org/kohsuke/github/GHRepository.java index deaf4aeaff..a20aac28eb 100644 --- a/src/main/java/org/kohsuke/github/GHRepository.java +++ b/src/main/java/org/kohsuke/github/GHRepository.java @@ -103,6 +103,8 @@ public class GHRepository extends GHObject { private boolean allow_rebase_merge; + private boolean allow_forking; + private boolean delete_branch_on_merge; @JsonProperty("private") @@ -715,6 +717,15 @@ public boolean isAllowRebaseMerge() { return allow_rebase_merge; } + /** + * Is allow private forks + * + * @return the boolean + */ + public boolean isAllowForking() { + return allow_forking; + } + /** * Automatically deleting head branches when pull requests are merged. * @@ -1461,6 +1472,18 @@ public void allowRebaseMerge(boolean value) throws IOException { set().allowRebaseMerge(value); } + /** + * Allow private fork. + * + * @param value + * the value + * @throws IOException + * the io exception + */ + public void allowForking(boolean value) throws IOException { + set().allowForking(value); + } + /** * After pull requests are merged, you can have head branches deleted automatically. * diff --git a/src/main/java/org/kohsuke/github/GHRepositoryBuilder.java b/src/main/java/org/kohsuke/github/GHRepositoryBuilder.java index 1d8602a044..a7b5b11a72 100644 --- a/src/main/java/org/kohsuke/github/GHRepositoryBuilder.java +++ b/src/main/java/org/kohsuke/github/GHRepositoryBuilder.java @@ -76,6 +76,19 @@ public S allowRebaseMerge(boolean enabled) throws IOException { return with("allow_rebase_merge", enabled); } + /** + * Allow or disallow private forks + * + * @param enabled + * true if enabled + * @return a builder to continue with building + * @throws IOException + * In case of any networking error or error from the server. + */ + public S allowForking(boolean enabled) throws IOException { + return with("allow_forking", enabled); + } + /** * After pull requests are merged, you can have head branches deleted automatically. * diff --git a/src/test/java/org/kohsuke/github/AbstractGitHubWireMockTest.java b/src/test/java/org/kohsuke/github/AbstractGitHubWireMockTest.java index 990583c945..044a7122ec 100644 --- a/src/test/java/org/kohsuke/github/AbstractGitHubWireMockTest.java +++ b/src/test/java/org/kohsuke/github/AbstractGitHubWireMockTest.java @@ -226,7 +226,7 @@ protected GHRepository getTempRepository() throws IOException { * Creates a temporary repository that will be deleted at the end of the test. * * @param name - * string name of the the repository + * string name of the repository * * @return a temporary repository * @throws IOException diff --git a/src/test/java/org/kohsuke/github/GHRepositoryTest.java b/src/test/java/org/kohsuke/github/GHRepositoryTest.java index d0ff0f73e1..61ca35c9c8 100644 --- a/src/test/java/org/kohsuke/github/GHRepositoryTest.java +++ b/src/test/java/org/kohsuke/github/GHRepositoryTest.java @@ -98,6 +98,7 @@ public void testGetters() throws IOException { assertThat(r.isAllowMergeCommit(), is(true)); assertThat(r.isAllowRebaseMerge(), is(true)); assertThat(r.isAllowSquashMerge(), is(true)); + assertThat(r.isAllowForking(), is(false)); String httpTransport = "https://github.com/hub4j-test-org/temp-testGetters.git"; assertThat(r.getHttpTransportUrl(), equalTo(httpTransport)); @@ -380,6 +381,7 @@ public void testUpdateRepository() throws Exception { GHRepository updated = builder.allowRebaseMerge(false) .allowSquashMerge(false) .deleteBranchOnMerge(true) + .allowForking(true) .description(description) .downloads(false) .downloads(false) @@ -394,6 +396,7 @@ public void testUpdateRepository() throws Exception { assertThat(updated.isAllowRebaseMerge(), is(false)); assertThat(updated.isAllowSquashMerge(), is(false)); assertThat(updated.isDeleteBranchOnMerge(), is(true)); + assertThat(updated.isAllowForking(), is(true)); assertThat(updated.isPrivate(), is(true)); assertThat(updated.hasDownloads(), is(false)); assertThat(updated.hasIssues(), is(false)); diff --git a/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/testGetters/__files/repos_hub4j-test-org_temp-testgetters-2.json b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/testGetters/__files/repos_hub4j-test-org_temp-testgetters-2.json index f8d16217fc..dac8e119fa 100644 --- a/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/testGetters/__files/repos_hub4j-test-org_temp-testgetters-2.json +++ b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/testGetters/__files/repos_hub4j-test-org_temp-testgetters-2.json @@ -101,6 +101,7 @@ "allow_merge_commit": true, "allow_rebase_merge": true, "delete_branch_on_merge": false, + "allow_forking": false, "organization": { "login": "hub4j-test-org", "id": 7544739, @@ -123,4 +124,4 @@ }, "network_count": 0, "subscribers_count": 7 -} \ No newline at end of file +} diff --git a/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/testUpdateRepository/__files/repos_hub4j-test-org_temp-testupdaterepository-2.json b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/testUpdateRepository/__files/repos_hub4j-test-org_temp-testupdaterepository-2.json index a6f5e84b2c..b35dc8ffd7 100644 --- a/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/testUpdateRepository/__files/repos_hub4j-test-org_temp-testupdaterepository-2.json +++ b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/testUpdateRepository/__files/repos_hub4j-test-org_temp-testupdaterepository-2.json @@ -101,6 +101,7 @@ "allow_merge_commit": true, "allow_rebase_merge": true, "delete_branch_on_merge": false, + "allow_forking": false, "organization": { "login": "hub4j-test-org", "id": 7544739, @@ -123,4 +124,4 @@ }, "network_count": 0, "subscribers_count": 9 -} \ No newline at end of file +} diff --git a/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/testUpdateRepository/__files/repos_hub4j-test-org_temp-testupdaterepository-3.json b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/testUpdateRepository/__files/repos_hub4j-test-org_temp-testupdaterepository-3.json index d62845bc50..ed4894e9e9 100644 --- a/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/testUpdateRepository/__files/repos_hub4j-test-org_temp-testupdaterepository-3.json +++ b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/testUpdateRepository/__files/repos_hub4j-test-org_temp-testupdaterepository-3.json @@ -100,6 +100,7 @@ "allow_merge_commit": true, "allow_rebase_merge": false, "delete_branch_on_merge": true, + "allow_forking": true, "organization": { "login": "hub4j-test-org", "id": 7544739, @@ -122,4 +123,4 @@ }, "network_count": 0, "subscribers_count": 9 -} \ No newline at end of file +} diff --git a/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/testUpdateRepository/__files/repos_hub4j-test-org_temp-testupdaterepository-4.json b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/testUpdateRepository/__files/repos_hub4j-test-org_temp-testupdaterepository-4.json index 8c2ad19854..8e4d6e85ba 100644 --- a/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/testUpdateRepository/__files/repos_hub4j-test-org_temp-testupdaterepository-4.json +++ b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/testUpdateRepository/__files/repos_hub4j-test-org_temp-testupdaterepository-4.json @@ -100,6 +100,7 @@ "allow_merge_commit": false, "allow_rebase_merge": true, "delete_branch_on_merge": true, + "allow_forking": false, "organization": { "login": "hub4j-test-org", "id": 7544739, @@ -122,4 +123,4 @@ }, "network_count": 0, "subscribers_count": 9 -} \ No newline at end of file +} diff --git a/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/testUpdateRepository/__files/repos_hub4j-test-org_temp-testupdaterepository-5.json b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/testUpdateRepository/__files/repos_hub4j-test-org_temp-testupdaterepository-5.json index 3ce310fccf..88ad46243c 100644 --- a/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/testUpdateRepository/__files/repos_hub4j-test-org_temp-testupdaterepository-5.json +++ b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/testUpdateRepository/__files/repos_hub4j-test-org_temp-testupdaterepository-5.json @@ -100,6 +100,7 @@ "allow_merge_commit": false, "allow_rebase_merge": true, "delete_branch_on_merge": true, + "allow_forking": false, "organization": { "login": "hub4j-test-org", "id": 7544739, @@ -122,4 +123,4 @@ }, "network_count": 0, "subscribers_count": 9 -} \ No newline at end of file +} diff --git a/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/testUpdateRepository/mappings/repos_hub4j-test-org_temp-testupdaterepository-3.json b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/testUpdateRepository/mappings/repos_hub4j-test-org_temp-testupdaterepository-3.json index 8596d7744c..38d758a008 100644 --- a/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/testUpdateRepository/mappings/repos_hub4j-test-org_temp-testupdaterepository-3.json +++ b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/testUpdateRepository/mappings/repos_hub4j-test-org_temp-testupdaterepository-3.json @@ -11,7 +11,7 @@ }, "bodyPatterns": [ { - "equalToJson": "{\"name\":\"temp-testUpdateRepository\",\"has_projects\":false,\"allow_squash_merge\":false,\"private\":true,\"has_downloads\":false,\"has_wiki\":false,\"description\":\"A test repository for update testing via the github-api project\",\"delete_branch_on_merge\":true,\"allow_rebase_merge\":false,\"has_issues\":false,\"homepage\":\"https://github-api.kohsuke.org/apidocs/index.html\"}", + "equalToJson": "{\"name\":\"temp-testUpdateRepository\",\"has_projects\":false,\"allow_squash_merge\":false,\"allow_forking\":true,\"private\":true,\"has_downloads\":false,\"has_wiki\":false,\"description\":\"A test repository for update testing via the github-api project\",\"delete_branch_on_merge\":true,\"allow_rebase_merge\":false,\"has_issues\":false,\"homepage\":\"https://github-api.kohsuke.org/apidocs/index.html\"}", "ignoreArrayOrder": true, "ignoreExtraElements": false } @@ -51,4 +51,4 @@ "uuid": "d0036ebb-64a8-4c4c-bed3-697870892d5f", "persistent": true, "insertionIndex": 3 -} \ No newline at end of file +}