Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add allow_forking flag for a GHRepository #1709

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions src/main/java/org/kohsuke/github/GHRepository.java
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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.
*
Expand Down Expand Up @@ -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.
*
Expand Down
13 changes: 13 additions & 0 deletions src/main/java/org/kohsuke/github/GHRepositoryBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions src/test/java/org/kohsuke/github/GHRepositoryTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down Expand Up @@ -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)
Expand All @@ -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));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -123,4 +124,4 @@
},
"network_count": 0,
"subscribers_count": 7
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -123,4 +124,4 @@
},
"network_count": 0,
"subscribers_count": 9
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -122,4 +123,4 @@
},
"network_count": 0,
"subscribers_count": 9
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -122,4 +123,4 @@
},
"network_count": 0,
"subscribers_count": 9
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -122,4 +123,4 @@
},
"network_count": 0,
"subscribers_count": 9
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -51,4 +51,4 @@
"uuid": "d0036ebb-64a8-4c4c-bed3-697870892d5f",
"persistent": true,
"insertionIndex": 3
}
}