Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 320416d

Browse filesBrowse files
authored
Merge pull request hub4j#1709 from panilya/feature/hub4jgh-1588-introduce-allow-forking-flag-repository
Add allow_forking flag for a GHRepository
2 parents 363318b + 9f5f4ef commit 320416d
Copy full SHA for 320416d
Expand file treeCollapse file tree

10 files changed

+52
-8
lines changed

‎src/main/java/org/kohsuke/github/GHRepository.java

Copy file name to clipboardExpand all lines: src/main/java/org/kohsuke/github/GHRepository.java
+23Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,8 @@ public class GHRepository extends GHObject {
103103

104104
private boolean allow_rebase_merge;
105105

106+
private boolean allow_forking;
107+
106108
private boolean delete_branch_on_merge;
107109

108110
@JsonProperty("private")
@@ -715,6 +717,15 @@ public boolean isAllowRebaseMerge() {
715717
return allow_rebase_merge;
716718
}
717719

720+
/**
721+
* Is allow private forks
722+
*
723+
* @return the boolean
724+
*/
725+
public boolean isAllowForking() {
726+
return allow_forking;
727+
}
728+
718729
/**
719730
* Automatically deleting head branches when pull requests are merged.
720731
*
@@ -1461,6 +1472,18 @@ public void allowRebaseMerge(boolean value) throws IOException {
14611472
set().allowRebaseMerge(value);
14621473
}
14631474

1475+
/**
1476+
* Allow private fork.
1477+
*
1478+
* @param value
1479+
* the value
1480+
* @throws IOException
1481+
* the io exception
1482+
*/
1483+
public void allowForking(boolean value) throws IOException {
1484+
set().allowForking(value);
1485+
}
1486+
14641487
/**
14651488
* After pull requests are merged, you can have head branches deleted automatically.
14661489
*

‎src/main/java/org/kohsuke/github/GHRepositoryBuilder.java

Copy file name to clipboardExpand all lines: src/main/java/org/kohsuke/github/GHRepositoryBuilder.java
+13Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,19 @@ public S allowRebaseMerge(boolean enabled) throws IOException {
7676
return with("allow_rebase_merge", enabled);
7777
}
7878

79+
/**
80+
* Allow or disallow private forks
81+
*
82+
* @param enabled
83+
* true if enabled
84+
* @return a builder to continue with building
85+
* @throws IOException
86+
* In case of any networking error or error from the server.
87+
*/
88+
public S allowForking(boolean enabled) throws IOException {
89+
return with("allow_forking", enabled);
90+
}
91+
7992
/**
8093
* After pull requests are merged, you can have head branches deleted automatically.
8194
*

‎src/test/java/org/kohsuke/github/AbstractGitHubWireMockTest.java

Copy file name to clipboardExpand all lines: src/test/java/org/kohsuke/github/AbstractGitHubWireMockTest.java
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ protected GHRepository getTempRepository() throws IOException {
226226
* Creates a temporary repository that will be deleted at the end of the test.
227227
*
228228
* @param name
229-
* string name of the the repository
229+
* string name of the repository
230230
*
231231
* @return a temporary repository
232232
* @throws IOException

‎src/test/java/org/kohsuke/github/GHRepositoryTest.java

Copy file name to clipboardExpand all lines: src/test/java/org/kohsuke/github/GHRepositoryTest.java
+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ public void testGetters() throws IOException {
9898
assertThat(r.isAllowMergeCommit(), is(true));
9999
assertThat(r.isAllowRebaseMerge(), is(true));
100100
assertThat(r.isAllowSquashMerge(), is(true));
101+
assertThat(r.isAllowForking(), is(false));
101102

102103
String httpTransport = "https://github.com/hub4j-test-org/temp-testGetters.git";
103104
assertThat(r.getHttpTransportUrl(), equalTo(httpTransport));
@@ -380,6 +381,7 @@ public void testUpdateRepository() throws Exception {
380381
GHRepository updated = builder.allowRebaseMerge(false)
381382
.allowSquashMerge(false)
382383
.deleteBranchOnMerge(true)
384+
.allowForking(true)
383385
.description(description)
384386
.downloads(false)
385387
.downloads(false)
@@ -394,6 +396,7 @@ public void testUpdateRepository() throws Exception {
394396
assertThat(updated.isAllowRebaseMerge(), is(false));
395397
assertThat(updated.isAllowSquashMerge(), is(false));
396398
assertThat(updated.isDeleteBranchOnMerge(), is(true));
399+
assertThat(updated.isAllowForking(), is(true));
397400
assertThat(updated.isPrivate(), is(true));
398401
assertThat(updated.hasDownloads(), is(false));
399402
assertThat(updated.hasIssues(), is(false));

‎src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/testGetters/__files/repos_hub4j-test-org_temp-testgetters-2.json

Copy file name to clipboardExpand all lines: src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/testGetters/__files/repos_hub4j-test-org_temp-testgetters-2.json
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@
101101
"allow_merge_commit": true,
102102
"allow_rebase_merge": true,
103103
"delete_branch_on_merge": false,
104+
"allow_forking": false,
104105
"organization": {
105106
"login": "hub4j-test-org",
106107
"id": 7544739,
@@ -123,4 +124,4 @@
123124
},
124125
"network_count": 0,
125126
"subscribers_count": 7
126-
}
127+
}

‎src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/testUpdateRepository/__files/repos_hub4j-test-org_temp-testupdaterepository-2.json

Copy file name to clipboardExpand all lines: src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/testUpdateRepository/__files/repos_hub4j-test-org_temp-testupdaterepository-2.json
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@
101101
"allow_merge_commit": true,
102102
"allow_rebase_merge": true,
103103
"delete_branch_on_merge": false,
104+
"allow_forking": false,
104105
"organization": {
105106
"login": "hub4j-test-org",
106107
"id": 7544739,
@@ -123,4 +124,4 @@
123124
},
124125
"network_count": 0,
125126
"subscribers_count": 9
126-
}
127+
}

‎src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/testUpdateRepository/__files/repos_hub4j-test-org_temp-testupdaterepository-3.json

Copy file name to clipboardExpand all lines: src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/testUpdateRepository/__files/repos_hub4j-test-org_temp-testupdaterepository-3.json
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@
100100
"allow_merge_commit": true,
101101
"allow_rebase_merge": false,
102102
"delete_branch_on_merge": true,
103+
"allow_forking": true,
103104
"organization": {
104105
"login": "hub4j-test-org",
105106
"id": 7544739,
@@ -122,4 +123,4 @@
122123
},
123124
"network_count": 0,
124125
"subscribers_count": 9
125-
}
126+
}

‎src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/testUpdateRepository/__files/repos_hub4j-test-org_temp-testupdaterepository-4.json

Copy file name to clipboardExpand all lines: src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/testUpdateRepository/__files/repos_hub4j-test-org_temp-testupdaterepository-4.json
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@
100100
"allow_merge_commit": false,
101101
"allow_rebase_merge": true,
102102
"delete_branch_on_merge": true,
103+
"allow_forking": false,
103104
"organization": {
104105
"login": "hub4j-test-org",
105106
"id": 7544739,
@@ -122,4 +123,4 @@
122123
},
123124
"network_count": 0,
124125
"subscribers_count": 9
125-
}
126+
}

‎src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/testUpdateRepository/__files/repos_hub4j-test-org_temp-testupdaterepository-5.json

Copy file name to clipboardExpand all lines: src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/testUpdateRepository/__files/repos_hub4j-test-org_temp-testupdaterepository-5.json
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@
100100
"allow_merge_commit": false,
101101
"allow_rebase_merge": true,
102102
"delete_branch_on_merge": true,
103+
"allow_forking": false,
103104
"organization": {
104105
"login": "hub4j-test-org",
105106
"id": 7544739,
@@ -122,4 +123,4 @@
122123
},
123124
"network_count": 0,
124125
"subscribers_count": 9
125-
}
126+
}

‎src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/testUpdateRepository/mappings/repos_hub4j-test-org_temp-testupdaterepository-3.json

Copy file name to clipboardExpand all lines: src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/testUpdateRepository/mappings/repos_hub4j-test-org_temp-testupdaterepository-3.json
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
},
1212
"bodyPatterns": [
1313
{
14-
"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\"}",
14+
"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\"}",
1515
"ignoreArrayOrder": true,
1616
"ignoreExtraElements": false
1717
}
@@ -51,4 +51,4 @@
5151
"uuid": "d0036ebb-64a8-4c4c-bed3-697870892d5f",
5252
"persistent": true,
5353
"insertionIndex": 3
54-
}
54+
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.