Skip to content

Commit

Permalink
Merge pull request #1709 from panilya/feature/gh-1588-introduce-allow…
Browse files Browse the repository at this point in the history
…-forking-flag-repository

Add allow_forking flag for a GHRepository
  • Loading branch information
bitwiseman authored Oct 19, 2023
2 parents 363318b + 9f5f4ef commit 320416d
Show file tree
Hide file tree
Showing 10 changed files with 52 additions and 8 deletions.
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
}
}

0 comments on commit 320416d

Please sign in to comment.