Skip to content

Commit

Permalink
Merge branch 'main' into feature/extend-pull-requests-query-search
Browse files Browse the repository at this point in the history
  • Loading branch information
bitwiseman authored Oct 20, 2023
2 parents dc0a8fa + 38baf5d commit ea17ade
Show file tree
Hide file tree
Showing 47 changed files with 2,264 additions and 33 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/maven-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
strategy:
fail-fast: true
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up JDK
uses: actions/setup-java@v3
with:
Expand All @@ -46,7 +46,7 @@ jobs:
strategy:
fail-fast: false
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up JDK
uses: actions/setup-java@v3
with:
Expand All @@ -66,7 +66,7 @@ jobs:
os: [ ubuntu, windows ]
java: [ 11, 17 ]
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up JDK
uses: actions/setup-java@v3
with:
Expand All @@ -93,7 +93,7 @@ jobs:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: actions/download-artifact@v3
with:
name: maven-target-directory
Expand Down
6 changes: 3 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.kohsuke</groupId>
<artifactId>github-api</artifactId>
<version>1.317-SNAPSHOT</version>
<version>1.318-SNAPSHOT</version>
<name>GitHub API for Java</name>
<url>https://github-api.kohsuke.org/</url>
<description>GitHub API for Java</description>
Expand Down Expand Up @@ -553,7 +553,7 @@
<dependency>
<groupId>org.eclipse.jgit</groupId>
<artifactId>org.eclipse.jgit</artifactId>
<version>6.4.0.202211300538-r</version>
<version>6.7.0.202309050840-r</version>
<scope>test</scope>
</dependency>
<dependency>
Expand Down Expand Up @@ -621,7 +621,7 @@
<dependency>
<groupId>com.github.tomakehurst</groupId>
<artifactId>wiremock-jre8-standalone</artifactId>
<version>2.35.0</version>
<version>2.35.1</version>
<scope>test</scope>
</dependency>
<dependency>
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/org/kohsuke/github/GHEvent.java
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,9 @@ public enum GHEvent {
/** The merge queue entry. */
MERGE_QUEUE_ENTRY,

/** The merge group entry. */
MERGE_GROUP,

/** The meta. */
META,

Expand Down
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
47 changes: 31 additions & 16 deletions src/main/java/org/kohsuke/github/GHVerification.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,48 +61,63 @@ public String getPayload() {
* The possible values for reason in verification object from github.
*
* @author Sourabh Sarvotham Parkala
* @see <a href="https://developer.github.com/v3/repos/commits/#signature-verification-object">List of possible
* reason values</a>
* @see <a href="https://docs.github.com/en/graphql/reference/enums#gitsignaturestate">List of possible reason
* values. Note graphQL documentation has currently the most updated values.</a>
*/
public enum Reason {

/** The expired key. */
/** Signing key expired. */
EXPIRED_KEY,

/** The not signing key. */
/** The usage flags for the key that signed this don't allow signing. */
NOT_SIGNING_KEY,

/** The gpgverify error. */
/** The GPG verification service misbehaved. */
GPGVERIFY_ERROR,

/** The gpgverify unavailable. */
/** The GPG verification service is unavailable at the moment. */
GPGVERIFY_UNAVAILABLE,

/** The unsigned. */
/** Unsigned. */
UNSIGNED,

/** The unknown signature type. */
/** Unknown signature type. */
UNKNOWN_SIGNATURE_TYPE,

/** The no user. */
/** Email used for signing not known to GitHub. */
NO_USER,

/** The unverified email. */
/** Email used for signing unverified on GitHub. */
UNVERIFIED_EMAIL,

/** The bad email. */
/** Invalid email used for signing. */
BAD_EMAIL,

/** The unknown key. */
/** Key used for signing not known to GitHub. */
UNKNOWN_KEY,

/** The malformed signature. */
/** Malformed signature. */
MALFORMED_SIGNATURE,

/** The invalid. */
/** Invalid signature. */
INVALID,

/** The valid. */
VALID
/** Valid signature and verified by GitHub. */
VALID,

/** The signing certificate or its chain could not be verified. */
BAD_CERT,

/** Malformed signature. (Returned by graphQL) */
MALFORMED_SIG,

/** Valid signature, though certificate revocation check failed. */
OCSP_ERROR,

/** Valid signature, pending certificate revocation checking. */
OCSP_PENDING,

/** One or more certificates in chain has been revoked. */
OCSP_REVOKED
}
}
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
2 changes: 1 addition & 1 deletion src/test/java/org/kohsuke/github/EnumTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public void touchEnums() {

assertThat(GHDirection.values().length, equalTo(2));

assertThat(GHEvent.values().length, equalTo(64));
assertThat(GHEvent.values().length, equalTo(65));
assertThat(GHEvent.ALL.symbol(), equalTo("*"));
assertThat(GHEvent.PULL_REQUEST.symbol(), equalTo(GHEvent.PULL_REQUEST.toString().toLowerCase()));

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 @@ -95,6 +95,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 @@ -377,6 +378,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 @@ -391,6 +393,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
84 changes: 84 additions & 0 deletions src/test/java/org/kohsuke/github/GHVerificationReasonTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -217,4 +217,88 @@ public void testValid() throws Exception {
assertThat(commit.getCommitShortInfo().getVerification().getPayload(), notNullValue());
assertThat(commit.getCommitShortInfo().getVerification().getSignature(), notNullValue());
}

/**
* Test bad cert.
*
* @throws Exception
* the exception
*/
@Test
public void testBadCert() throws Exception {
GHRepository r = gitHub.getRepository("hub4j/github-api");
GHCommit commit = r.getCommit("86a2e245aa6d71d54923655066049d9e21a15f01");
assertThat(commit.getCommitShortInfo().getAuthor().getName(), equalTo("Sourabh Parkala"));
assertThat(commit.getCommitShortInfo().getVerification().getSignature(), notNullValue());
assertThat(commit.getCommitShortInfo().getVerification().isVerified(), is(false));
assertThat(commit.getCommitShortInfo().getVerification().getReason(), equalTo(GHVerification.Reason.BAD_CERT));
}

/**
* Test malformed sig.
*
* @throws Exception
* the exception
*/
@Test
public void testMalformedSig() throws Exception {
GHRepository r = gitHub.getRepository("hub4j/github-api");
GHCommit commit = r.getCommit("86a2e245aa6d71d54923655066049d9e21a15f01");
assertThat(commit.getCommitShortInfo().getAuthor().getName(), equalTo("Sourabh Parkala"));
assertThat(commit.getCommitShortInfo().getVerification().getSignature(), notNullValue());
assertThat(commit.getCommitShortInfo().getVerification().isVerified(), is(false));
assertThat(commit.getCommitShortInfo().getVerification().getReason(),
equalTo(GHVerification.Reason.MALFORMED_SIG));
}

/**
* Test OSCP error.
*
* @throws Exception
* the exception
*/
@Test
public void testOcspError() throws Exception {
GHRepository r = gitHub.getRepository("hub4j/github-api");
GHCommit commit = r.getCommit("86a2e245aa6d71d54923655066049d9e21a15f01");
assertThat(commit.getCommitShortInfo().getAuthor().getName(), equalTo("Sourabh Parkala"));
assertThat(commit.getCommitShortInfo().getVerification().getSignature(), notNullValue());
assertThat(commit.getCommitShortInfo().getVerification().isVerified(), is(false));
assertThat(commit.getCommitShortInfo().getVerification().getReason(),
equalTo(GHVerification.Reason.OCSP_ERROR));
}

/**
* Test OSCP pending.
*
* @throws Exception
* the exception
*/
@Test
public void testOscpPending() throws Exception {
GHRepository r = gitHub.getRepository("hub4j/github-api");
GHCommit commit = r.getCommit("86a2e245aa6d71d54923655066049d9e21a15f01");
assertThat(commit.getCommitShortInfo().getAuthor().getName(), equalTo("Sourabh Parkala"));
assertThat(commit.getCommitShortInfo().getVerification().getSignature(), notNullValue());
assertThat(commit.getCommitShortInfo().getVerification().isVerified(), is(false));
assertThat(commit.getCommitShortInfo().getVerification().getReason(),
equalTo(GHVerification.Reason.OCSP_PENDING));
}

/**
* Test OCSP revoked.
*
* @throws Exception
* the exception
*/
@Test
public void testOscpRevoked() throws Exception {
GHRepository r = gitHub.getRepository("hub4j/github-api");
GHCommit commit = r.getCommit("86a2e245aa6d71d54923655066049d9e21a15f01");
assertThat(commit.getCommitShortInfo().getAuthor().getName(), equalTo("Sourabh Parkala"));
assertThat(commit.getCommitShortInfo().getVerification().getSignature(), notNullValue());
assertThat(commit.getCommitShortInfo().getVerification().isVerified(), is(false));
assertThat(commit.getCommitShortInfo().getVerification().getReason(),
equalTo(GHVerification.Reason.OCSP_REVOKED));
}
}
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
}
}
Loading

0 comments on commit ea17ade

Please sign in to comment.