diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md
index 0815906c23..2ffe6c4da9 100644
--- a/.github/PULL_REQUEST_TEMPLATE.md
+++ b/.github/PULL_REQUEST_TEMPLATE.md
@@ -8,7 +8,7 @@
- [ ] Add JavaDocs and other comments explaining the behavior.
- [ ] When adding or updating methods that fetch entities, add `@link` JavaDoc entries to the relevant documentation on https://docs.github.com/en/rest .
- [ ] Add tests that cover any added or changed code. This generally requires capturing snapshot test data. See [CONTRIBUTING.md](CONTRIBUTING.md) for details.
-- [ ] Run `mvn -D enable-ci clean install site` locally. If this command doesn't succeed, your change will not pass CI.
+- [ ] Run `mvn -D enable-ci clean install site "-Dsurefire.argLine=--add-opens java.base/java.net=ALL-UNNAMED"` locally. If this command doesn't succeed, your change will not pass CI.
- [ ] Push your changes to a branch other than `main`. You will create your PR from that branch.
# When creating a PR:
diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml
index ebb0d6b9c8..1f4364ff27 100644
--- a/.github/workflows/codeql-analysis.yml
+++ b/.github/workflows/codeql-analysis.yml
@@ -42,13 +42,13 @@ jobs:
steps:
- name: Set up JDK
- uses: actions/setup-java@v4
+ uses: actions/setup-java@v5
with:
distribution: 'temurin'
java-version: 17
- name: Checkout repository
- uses: actions/checkout@v4
+ uses: actions/checkout@v5
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
diff --git a/.github/workflows/create_release_tag_and_pr.yml b/.github/workflows/create_release_tag_and_pr.yml
index 16a59223f5..ec67d46e4b 100644
--- a/.github/workflows/create_release_tag_and_pr.yml
+++ b/.github/workflows/create_release_tag_and_pr.yml
@@ -10,22 +10,24 @@ jobs:
create_release_tag:
runs-on: ubuntu-latest
steps:
- - uses: actions/checkout@v4
+ - uses: actions/checkout@v5
with:
fetch-depth: 0
- name: Set up Maven Central Repository
- uses: actions/setup-java@v4
+ uses: actions/setup-java@v5
with:
java-version: '17'
distribution: 'temurin'
cache: 'maven'
- - name: Reset staging/main
+ - name: Reset staging
id: staging
run: |
- git checkout -B staging/main
- git push --set-upstream -f origin staging/main
+ git checkout -B staging/$GITHUB_REF_NAME
+ git push --set-upstream -f origin staging/$GITHUB_REF_NAME
+ env:
+ GITHUB_REF_NAME: ${{ github.ref_name }}
- name: Set Release Version
id: release
@@ -33,25 +35,25 @@ jobs:
mvn -B versions:set versions:commit -DremoveSnapshot
echo "version=$(mvn -B help:evaluate -Dexpression=project.version -q -DforceStdout)" >> $GITHUB_OUTPUT
- - uses: stefanzweifel/git-auto-commit-action@v5
+ - uses: stefanzweifel/git-auto-commit-action@v6
with:
commit_message: "Prepare release (${{ github.actor }}): github-api-${{ steps.release.outputs.version }}"
tagging_message: 'github-api-${{ steps.release.outputs.version }}'
- branch: staging/main
+ branch: staging/${{ github.ref_name }}
- name: Increment Snapshot Version
run: |
mvn versions:set versions:commit -DnextSnapshot
- - uses: stefanzweifel/git-auto-commit-action@v5
+ - uses: stefanzweifel/git-auto-commit-action@v6
with:
commit_message: "Prepare for next development iteration"
- branch: staging/main
+ branch: staging/${{ github.ref_name }}
- - name: pull-request to main
+ - name: Create pull-request
uses: repo-sync/pull-request@v2
with:
pr_title: "Prepare release (${{ github.actor }}): github-api-${{ steps.release.outputs.version }}"
- source_branch: "staging/main"
- destination_branch: "main"
+ source_branch: "staging/${{ github.ref_name }}"
+ destination_branch: "${{ github.ref_name }}"
github_token: ${{ secrets.GITHUB_TOKEN }}
diff --git a/.github/workflows/maven-build.yml b/.github/workflows/maven-build.yml
index 019b655490..867a390089 100644
--- a/.github/workflows/maven-build.yml
+++ b/.github/workflows/maven-build.yml
@@ -25,9 +25,9 @@ jobs:
strategy:
fail-fast: true
steps:
- - uses: actions/checkout@v4
+ - uses: actions/checkout@v5
- name: Set up JDK
- uses: actions/setup-java@v4
+ uses: actions/setup-java@v5
with:
java-version: 17
distribution: 'temurin'
@@ -47,9 +47,9 @@ jobs:
strategy:
fail-fast: false
steps:
- - uses: actions/checkout@v4
+ - uses: actions/checkout@v5
- name: Set up JDK
- uses: actions/setup-java@v4
+ uses: actions/setup-java@v5
with:
java-version: 17
distribution: 'temurin'
@@ -71,9 +71,9 @@ jobs:
os: [ ubuntu, windows ]
java: [ 17, 21 ]
steps:
- - uses: actions/checkout@v4
+ - uses: actions/checkout@v5
- name: Set up JDK
- uses: actions/setup-java@v4
+ uses: actions/setup-java@v5
with:
java-version: ${{ matrix.java }}
distribution: 'temurin'
@@ -98,16 +98,17 @@ jobs:
retention-days: 3
codecov-upload:
name: codecov-upload (Upload to codecov.io)
+ if: github.repository == 'hub4j/github-api'
needs: test
runs-on: ubuntu-latest
steps:
- - uses: actions/checkout@v4
- - uses: actions/download-artifact@v4
+ - uses: actions/checkout@v5
+ - uses: actions/download-artifact@v5
with:
name: maven-test-target-directory
path: target
- name: Codecov Report
- uses: codecov/codecov-action@v5.1.2
+ uses: codecov/codecov-action@v5.5.0
with:
# Codecov token from https://app.codecov.io/gh/hub4j/github-api/settings
token: ${{ secrets.CODECOV_TOKEN }}
@@ -138,13 +139,13 @@ jobs:
needs: build
runs-on: ubuntu-latest
steps:
- - uses: actions/checkout@v4
- - uses: actions/download-artifact@v4
+ - uses: actions/checkout@v5
+ - uses: actions/download-artifact@v5
with:
name: maven-target-directory
path: target
- name: Set up JDK
- uses: actions/setup-java@v4
+ uses: actions/setup-java@v5
with:
java-version: 11
distribution: 'temurin'
diff --git a/.github/workflows/publish_release_branch.yml b/.github/workflows/publish_release_branch.yml
index 6e3041a436..b57db51098 100644
--- a/.github/workflows/publish_release_branch.yml
+++ b/.github/workflows/publish_release_branch.yml
@@ -12,9 +12,9 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- - uses: actions/checkout@v4
+ - uses: actions/checkout@v5
- name: Set up Maven Central Repository
- uses: actions/setup-java@v4
+ uses: actions/setup-java@v5
with:
java-version: '17'
distribution: 'temurin'
@@ -35,9 +35,9 @@ jobs:
runs-on: ubuntu-latest
needs: build
steps:
- - uses: actions/checkout@v4
+ - uses: actions/checkout@v5
- name: Set up Maven Central Repository
- uses: actions/setup-java@v4
+ uses: actions/setup-java@v5
with:
java-version: '17'
distribution: 'temurin'
@@ -55,13 +55,13 @@ jobs:
MAVEN_USERNAME: ${{ secrets.OSSRH_TOKEN_USERNAME }}
MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN_PASSWORD }}
MAVEN_GPG_PASSPHRASE: ${{ secrets.OSSRH_GPG_SECRET_KEY_PASSPHRASE }}
-
+
publish_gh_pages:
runs-on: ubuntu-latest
needs: build
if: ${{ github.ref == 'refs/heads/release/v2.x' }}
steps:
- - uses: actions/checkout@v4
+ - uses: actions/checkout@v5
with:
fetch-depth: 0
@@ -70,7 +70,7 @@ jobs:
run: |
echo "version=$(mvn -B help:evaluate -Dexpression=project.version -q -DforceStdout)" >> $GITHUB_OUTPUT
- - uses: actions/download-artifact@v4
+ - uses: actions/download-artifact@v5
with:
name: maven-release-target-directory
path: target
@@ -82,7 +82,7 @@ jobs:
cp -r ./target/site/* ./
- name: Publish GH Pages
- uses: stefanzweifel/git-auto-commit-action@v5
+ uses: stefanzweifel/git-auto-commit-action@v6
with:
commit_message: "Release (${{ github.actor }}): v${{ steps.release.outputs.version }}"
branch: gh-pages
diff --git a/.gitignore b/.gitignore
index 543ce576cd..5a585eb651 100644
--- a/.gitignore
+++ b/.gitignore
@@ -6,6 +6,7 @@ target
.classpath
.project
.settings/
+.metadata/
.DS_Store
dependency-reduced-pom.xml
diff --git a/README.md b/README.md
index af8bdac4ff..fc42e705ca 100644
--- a/README.md
+++ b/README.md
@@ -35,4 +35,4 @@ Now the new version is available to be used in main project dependencies.
[](https://codecov.io/gh/hub4j/github-api)
-See https://github-api.kohsuke.org/ for more details
+See https://hub4j.github.io/github-api/ for more details
diff --git a/pom.xml b/pom.xml
index d54d3e3e39..06ba383440 100644
--- a/pom.xml
+++ b/pom.xml
@@ -2,7 +2,7 @@
4.0.0
org.kohsuke
github-api
- 1.327-ecwid-12
+ 1.330-ecwid-1
GitHub API for Java
https://github-api.kohsuke.org/
GitHub API for Java
@@ -18,12 +18,12 @@
sonatype-nexus-snapshots
Sonatype Nexus Snapshots
- https://s01.oss.sonatype.org/content/repositories/snapshots/
+ ${nexus.serverUrl}/content/repositories/snapshots/
sonatype-nexus-staging
Nexus Release Repository
- https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/
+ ${nexus.serverUrl}/service/local/staging/deploy/maven2/
github-pages
@@ -49,6 +49,9 @@
+
+
+ https://ossrh-staging-api.central.sonatype.com
@@ -237,7 +240,7 @@
true
sonatype-nexus-staging
- https://oss.sonatype.org/
+ ${nexus.serverUrl}/
true
@@ -475,7 +478,7 @@
com.fasterxml.jackson
jackson-bom
- 2.18.2
+ 2.20.0
import
pom
@@ -486,7 +489,7 @@
org.apache.commons
commons-lang3
- 3.17.0
+ 3.18.0
com.tngtech.archunit
diff --git a/src/main/java/org/kohsuke/github/GHBranch.java b/src/main/java/org/kohsuke/github/GHBranch.java
index 492f7e75b8..0f297a61ca 100644
--- a/src/main/java/org/kohsuke/github/GHBranch.java
+++ b/src/main/java/org/kohsuke/github/GHBranch.java
@@ -111,11 +111,18 @@ public GHBranchProtection getProtection() throws IOException {
return root().createRequest().setRawUrlPath(protection_url).fetch(GHBranchProtection.class);
}
- public PagedIterable getRules() throws IOException {
- return root().createRequest()
- .withUrlPath(owner.getApiTailUrl("rules/branches/" + name))
- .toIterable(GHRule[].class, GHRule::wrap);
- }
+ /**
+ * Lists rules configured for this branch.
+ *
+ * @return branch rules
+ * @throws IOException
+ * if an I/O error occurs
+ */
+ public PagedIterable getRules() throws IOException {
+ return root().createRequest()
+ .withUrlPath(owner.getApiTailUrl("rules/branches/" + name))
+ .toIterable(GHRule[].class, GHRule::wrap);
+ }
/**
* Gets sha 1.
diff --git a/src/main/java/org/kohsuke/github/GHCommit.java b/src/main/java/org/kohsuke/github/GHCommit.java
index a6d9322568..1cae2d7d07 100644
--- a/src/main/java/org/kohsuke/github/GHCommit.java
+++ b/src/main/java/org/kohsuke/github/GHCommit.java
@@ -350,40 +350,43 @@ public GHRepository getOwner() {
return owner;
}
- /**
- * Gets commit verification.
- * @return
- */
- public GHVerification getVerification() {
- return commit.getVerification();
- }
-
- /**
- * Gets commit author.
- * @return
- */
- public GitUser getCommitAuthor() {
- return commit.getAuthor();
- }
-
- /**
- * Gets commit committer.
- * @return
- */
- public GitUser getCommitCommitter() {
- return commit.getCommitter();
- }
-
- /**
- * Gets message.
- *
- * @return the commit message
- * @throws IOException
- * the io exception
- */
- public String getMessage() throws IOException {
- return getCommitShortInfo().getMessage();
- }
+ /**
+ * Gets commit verification.
+ *
+ * @return the commit verification
+ */
+ public GHVerification getVerification() {
+ return commit.getVerification();
+ }
+
+ /**
+ * Gets commit author.
+ *
+ * @return the commit author
+ */
+ public GitUser getCommitAuthor() {
+ return commit.getAuthor();
+ }
+
+ /**
+ * Gets commit committer.
+ *
+ * @return the commit committer
+ */
+ public GitUser getCommitCommitter() {
+ return commit.getCommitter();
+ }
+
+ /**
+ * Gets message.
+ *
+ * @return the commit message
+ * @throws IOException
+ * the io exception
+ */
+ public String getMessage() throws IOException {
+ return getCommitShortInfo().getMessage();
+ }
/**
* Gets lines changed.
*
diff --git a/src/main/java/org/kohsuke/github/GHEnvironmentVariable.java b/src/main/java/org/kohsuke/github/GHEnvironmentVariable.java
index dbf7fbb583..bb9fa2bf8b 100644
--- a/src/main/java/org/kohsuke/github/GHEnvironmentVariable.java
+++ b/src/main/java/org/kohsuke/github/GHEnvironmentVariable.java
@@ -1,8 +1,12 @@
package org.kohsuke.github;
-import javax.annotation.Nonnull;
import java.io.IOException;
+import javax.annotation.Nonnull;
+
+/**
+ * Environment variable configured for a repository environment.
+ */
public class GHEnvironmentVariable extends GitHubInteractiveObject {
private String name;
@@ -10,39 +14,91 @@ public class GHEnvironmentVariable extends GitHubInteractiveObject {
private String createdAt;
private String updatedAt;
+ /**
+ * Creates an environment variable instance.
+ */
+ public GHEnvironmentVariable() {
+ }
+
+ /**
+ * Gets the variable name.
+ *
+ * @return the variable name
+ */
public String getName() {
return name;
}
+ /**
+ * Sets the variable name.
+ *
+ * @param name
+ * the variable name
+ */
public void setName(String name) {
this.name = name;
}
+ /**
+ * Gets the variable value.
+ *
+ * @return the variable value
+ */
public String getValue() {
return value;
}
+ /**
+ * Sets the variable value.
+ *
+ * @param value
+ * the variable value
+ */
public void setValue(String value) {
this.value = value;
}
+ /**
+ * Gets the creation timestamp.
+ *
+ * @return the creation timestamp
+ */
public String getCreatedAt() {
return createdAt;
}
+ /**
+ * Sets the creation timestamp.
+ *
+ * @param createdAt
+ * the creation timestamp
+ */
public void setCreatedAt(String createdAt) {
this.createdAt = createdAt;
}
+ /**
+ * Gets the update timestamp.
+ *
+ * @return the update timestamp
+ */
public String getUpdatedAt() {
return updatedAt;
}
+ /**
+ * Sets the update timestamp.
+ *
+ * @param updatedAt
+ * the update timestamp
+ */
public void setUpdatedAt(String updatedAt) {
this.updatedAt = updatedAt;
}
- static GHEnvironmentVariable read(@Nonnull GHRepository repository, @Nonnull String environment, @Nonnull String name) throws IOException {
+ static GHEnvironmentVariable read(@Nonnull GHRepository repository,
+ @Nonnull String environment,
+ @Nonnull String name) throws IOException {
String url = "environments/" + environment + "/variables/" + name;
GHEnvironmentVariable variable = repository.root()
.createRequest()
diff --git a/src/main/java/org/kohsuke/github/GHPullRequestCommitDetail.java b/src/main/java/org/kohsuke/github/GHPullRequestCommitDetail.java
index 4586ff788c..c14b497102 100644
--- a/src/main/java/org/kohsuke/github/GHPullRequestCommitDetail.java
+++ b/src/main/java/org/kohsuke/github/GHPullRequestCommitDetail.java
@@ -67,8 +67,16 @@ void wrapUp(GHPullRequest owner) {
public static class GHCommitDetailAuthor {
String login;
+ /**
+ * Creates a commit detail author instance.
+ */
+ public GHCommitDetailAuthor() {
+ }
+
/**
* GitHub user login
+ *
+ * @return the GitHub user login
*/
public String getLogin() {
return login;
@@ -335,6 +343,7 @@ public CommitPointer[] getParents() {
/**
* Gets the GitHub user - author of the commit.
*
+ * @return the commit author
*/
public GHCommitDetailAuthor getAuthor() {
return author;
@@ -343,6 +352,7 @@ public GHCommitDetailAuthor getAuthor() {
/**
* Gets the GitHub user - committer of the commit.
*
+ * @return the commit committer
*/
public GHCommitDetailAuthor getCommitter() {
return committer;
diff --git a/src/main/java/org/kohsuke/github/GHPullRequestSearchBuilder.java b/src/main/java/org/kohsuke/github/GHPullRequestSearchBuilder.java
index 630a2d9cd8..ee15191642 100644
--- a/src/main/java/org/kohsuke/github/GHPullRequestSearchBuilder.java
+++ b/src/main/java/org/kohsuke/github/GHPullRequestSearchBuilder.java
@@ -469,14 +469,14 @@ public enum Sort {
UPDATED,
/** The relevance. */
RELEVANCE,
- /**
- * https://docs.github.com/en/enterprise-cloud@latest/search-github/getting-started-with-searching-on-github/sorting-search-results#sort-by-author-date
- */
- AUTHOR_DATE,
- /**
- * https://docs.github.com/en/enterprise-cloud@latest/search-github/getting-started-with-searching-on-github/sorting-search-results#sort-by-committer-date
- */
- COMMITTER_DATE,
+ /**
+ * https://docs.github.com/en/enterprise-cloud@latest/search-github/getting-started-with-searching-on-github/sorting-search-results#sort-by-author-date
+ */
+ AUTHOR_DATE,
+ /**
+ * https://docs.github.com/en/enterprise-cloud@latest/search-github/getting-started-with-searching-on-github/sorting-search-results#sort-by-committer-date
+ */
+ COMMITTER_DATE,
}
private static class PullRequestSearchResult extends SearchResult {
diff --git a/src/main/java/org/kohsuke/github/GHRule.java b/src/main/java/org/kohsuke/github/GHRule.java
index e0ddd3a3c7..4d17bd59d3 100644
--- a/src/main/java/org/kohsuke/github/GHRule.java
+++ b/src/main/java/org/kohsuke/github/GHRule.java
@@ -1,152 +1,337 @@
package org.kohsuke.github;
import com.fasterxml.jackson.annotation.JsonEnumDefaultValue;
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.util.Collection;
+/**
+ * Rule configured for a repository branch.
+ */
public class GHRule {
- private RuleType type;
- private Parameters parameters;
-
- public RuleType getType() {
- return type;
- }
-
- public void setType(RuleType type) {
- this.type = type;
- }
-
- public Parameters getParameters() {
- return parameters;
- }
-
- public void setParameters(Parameters parameters) {
- this.parameters = parameters;
- }
-
-
- public GHRule wrap() {
- return this;
- }
-
- public enum RuleType {
- commit_author_email_pattern,
- copilot_code_review,
- creation,
- deletion,
- merge_queue,
- non_fast_forward,
- pull_request,
- require_code_scanning,
- require_deployments,
- require_linear_history,
- required_signatures,
- required_status_checks,
- update,
-
- // Fallback for any rule type GitHub introduces in the future that this client
- // does not yet know about. Combined with READ_UNKNOWN_ENUM_VALUES_USING_DEFAULT_VALUE
- // in GitHubClient's ObjectMapper, this prevents deserialization failures on
- // new rule types and lets callers safely ignore them.
- @JsonEnumDefaultValue
- unknown,
- }
-
- public static class Parameters {
- private Collection required_status_checks;
- private MergeMethod merge_method;
- private Integer max_entries_to_build;
- private Integer min_entries_to_merge;
- private Integer max_entries_to_merge;
- private Integer min_entries_to_merge_wait_minutes;
- private Integer check_response_timeout_minutes;
- private GroupingStrategy grouping_strategy;
-
- public Collection getRequiredStatusChecks() {
- return required_status_checks;
- }
-
- public void setRequiredStatusChecks(Collection required_status_checks) {
- this.required_status_checks = required_status_checks;
- }
-
- public MergeMethod getMergeMethod() {
- return merge_method;
- }
-
- public void setMergeMethod(MergeMethod merge_method) {
- this.merge_method = merge_method;
- }
-
- public Integer getMaxEntriesToBuild() {
- return max_entries_to_build;
- }
-
- public void setMaxEntriesToBuild(Integer maxEntriesToBuild) {
- this.max_entries_to_build = maxEntriesToBuild;
- }
-
- public Integer getMinEntriesToMerge() {
- return min_entries_to_merge;
- }
-
- public void setMinEntriesToMerge(Integer minEntriesToMerge) {
- this.min_entries_to_merge = minEntriesToMerge;
- }
-
- public Integer getMaxEntriesToMerge() {
- return max_entries_to_merge;
- }
-
- public void setMaxEntriesToMerge(Integer maxEntriesToMerge) {
- this.max_entries_to_merge = maxEntriesToMerge;
- }
-
- public Integer getMinEntriesToMergeWaitMinutes() {
- return min_entries_to_merge_wait_minutes;
- }
-
- public void setMinEntriesToMergeWaitMinutes(Integer minEntriesToMergeWaitMinutes) {
- this.min_entries_to_merge_wait_minutes = minEntriesToMergeWaitMinutes;
- }
-
- public Integer getCheckResponseTimeoutMinutes() {
- return check_response_timeout_minutes;
- }
-
- public void setCheckResponseTimeoutMinutes(Integer checkResponseTimeoutMinutes) {
- this.check_response_timeout_minutes = checkResponseTimeoutMinutes;
- }
-
- public GroupingStrategy getGroupingStrategy() {
- return grouping_strategy;
- }
-
- public void setGroupingStrategy(GroupingStrategy groupingStrategy) {
- this.grouping_strategy = groupingStrategy;
- }
- }
-
- public static class RequiredCheck {
- private String context;
-
- public String getContext() {
- return context;
- }
-
- public void setContext(String context) {
- this.context = context;
- }
- }
-
- public enum MergeMethod {
- MERGE,
- SQUASH,
- REBASE
- }
-
- public enum GroupingStrategy {
- ALLGREEN,
- HEADGREEN
- }
+ private RuleType type;
+ private Parameters parameters;
+
+ /**
+ * Creates a branch rule instance.
+ */
+ public GHRule() {
+ }
+
+ /**
+ * Gets the rule type.
+ *
+ * @return the rule type
+ */
+ public RuleType getType() {
+ return type;
+ }
+
+ /**
+ * Sets the rule type.
+ *
+ * @param type
+ * the rule type
+ */
+ public void setType(RuleType type) {
+ this.type = type;
+ }
+
+ /**
+ * Gets the rule parameters.
+ *
+ * @return the rule parameters
+ */
+ @SuppressFBWarnings(value = { "EI_EXPOSE_REP" }, justification = "Expected behavior")
+ public Parameters getParameters() {
+ return parameters;
+ }
+
+ /**
+ * Sets the rule parameters.
+ *
+ * @param parameters
+ * the rule parameters
+ */
+ @SuppressFBWarnings(value = { "EI_EXPOSE_REP2" }, justification = "Expected behavior")
+ public void setParameters(Parameters parameters) {
+ this.parameters = parameters;
+ }
+
+ /**
+ * Wraps this rule.
+ *
+ * @return this rule
+ */
+ public GHRule wrap() {
+ return this;
+ }
+
+ /**
+ * Branch rule type.
+ */
+ public enum RuleType {
+ /** Commit author email pattern rule. */
+ commit_author_email_pattern,
+ /** Copilot code review rule. */
+ copilot_code_review,
+ /** Creation rule. */
+ creation,
+ /** Deletion rule. */
+ deletion,
+ /** Merge queue rule. */
+ merge_queue,
+ /** Non fast-forward rule. */
+ non_fast_forward,
+ /** Pull request rule. */
+ pull_request,
+ /** Code scanning rule. */
+ require_code_scanning,
+ /** Deployment rule. */
+ require_deployments,
+ /** Linear history rule. */
+ require_linear_history,
+ /** Required signatures rule. */
+ required_signatures,
+ /** Required status checks rule. */
+ required_status_checks,
+ /** Update rule. */
+ update,
+
+ // Fallback for any rule type GitHub introduces in the future that this client
+ // does not yet know about. Combined with READ_UNKNOWN_ENUM_VALUES_USING_DEFAULT_VALUE
+ // in GitHubClient's ObjectMapper, this prevents deserialization failures on
+ // new rule types and lets callers safely ignore them.
+ /** Unknown rule type. */
+ @JsonEnumDefaultValue
+ unknown,
+ }
+
+ /**
+ * Branch rule parameters.
+ */
+ public static class Parameters {
+ private Collection required_status_checks;
+ private MergeMethod merge_method;
+ private Integer max_entries_to_build;
+ private Integer min_entries_to_merge;
+ private Integer max_entries_to_merge;
+ private Integer min_entries_to_merge_wait_minutes;
+ private Integer check_response_timeout_minutes;
+ private GroupingStrategy grouping_strategy;
+
+ /**
+ * Creates branch rule parameters.
+ */
+ public Parameters() {
+ }
+
+ /**
+ * Gets required status checks.
+ *
+ * @return required status checks
+ */
+ @SuppressFBWarnings(value = { "EI_EXPOSE_REP" }, justification = "Expected behavior")
+ public Collection getRequiredStatusChecks() {
+ return required_status_checks;
+ }
+
+ /**
+ * Sets required status checks.
+ *
+ * @param required_status_checks
+ * required status checks
+ */
+ @SuppressFBWarnings(value = { "EI_EXPOSE_REP2" }, justification = "Expected behavior")
+ public void setRequiredStatusChecks(Collection required_status_checks) {
+ this.required_status_checks = required_status_checks;
+ }
+
+ /**
+ * Gets the merge method.
+ *
+ * @return the merge method
+ */
+ public MergeMethod getMergeMethod() {
+ return merge_method;
+ }
+
+ /**
+ * Sets the merge method.
+ *
+ * @param merge_method
+ * the merge method
+ */
+ public void setMergeMethod(MergeMethod merge_method) {
+ this.merge_method = merge_method;
+ }
+
+ /**
+ * Gets the maximum entries to build.
+ *
+ * @return the maximum entries to build
+ */
+ public Integer getMaxEntriesToBuild() {
+ return max_entries_to_build;
+ }
+
+ /**
+ * Sets the maximum entries to build.
+ *
+ * @param maxEntriesToBuild
+ * the maximum entries to build
+ */
+ public void setMaxEntriesToBuild(Integer maxEntriesToBuild) {
+ this.max_entries_to_build = maxEntriesToBuild;
+ }
+
+ /**
+ * Gets the minimum entries to merge.
+ *
+ * @return the minimum entries to merge
+ */
+ public Integer getMinEntriesToMerge() {
+ return min_entries_to_merge;
+ }
+
+ /**
+ * Sets the minimum entries to merge.
+ *
+ * @param minEntriesToMerge
+ * the minimum entries to merge
+ */
+ public void setMinEntriesToMerge(Integer minEntriesToMerge) {
+ this.min_entries_to_merge = minEntriesToMerge;
+ }
+
+ /**
+ * Gets the maximum entries to merge.
+ *
+ * @return the maximum entries to merge
+ */
+ public Integer getMaxEntriesToMerge() {
+ return max_entries_to_merge;
+ }
+
+ /**
+ * Sets the maximum entries to merge.
+ *
+ * @param maxEntriesToMerge
+ * the maximum entries to merge
+ */
+ public void setMaxEntriesToMerge(Integer maxEntriesToMerge) {
+ this.max_entries_to_merge = maxEntriesToMerge;
+ }
+
+ /**
+ * Gets the minimum entries to merge wait time in minutes.
+ *
+ * @return the minimum entries to merge wait time in minutes
+ */
+ public Integer getMinEntriesToMergeWaitMinutes() {
+ return min_entries_to_merge_wait_minutes;
+ }
+
+ /**
+ * Sets the minimum entries to merge wait time in minutes.
+ *
+ * @param minEntriesToMergeWaitMinutes
+ * the minimum entries to merge wait time in minutes
+ */
+ public void setMinEntriesToMergeWaitMinutes(Integer minEntriesToMergeWaitMinutes) {
+ this.min_entries_to_merge_wait_minutes = minEntriesToMergeWaitMinutes;
+ }
+
+ /**
+ * Gets the check response timeout in minutes.
+ *
+ * @return the check response timeout in minutes
+ */
+ public Integer getCheckResponseTimeoutMinutes() {
+ return check_response_timeout_minutes;
+ }
+
+ /**
+ * Sets the check response timeout in minutes.
+ *
+ * @param checkResponseTimeoutMinutes
+ * the check response timeout in minutes
+ */
+ public void setCheckResponseTimeoutMinutes(Integer checkResponseTimeoutMinutes) {
+ this.check_response_timeout_minutes = checkResponseTimeoutMinutes;
+ }
+
+ /**
+ * Gets the grouping strategy.
+ *
+ * @return the grouping strategy
+ */
+ public GroupingStrategy getGroupingStrategy() {
+ return grouping_strategy;
+ }
+
+ /**
+ * Sets the grouping strategy.
+ *
+ * @param groupingStrategy
+ * the grouping strategy
+ */
+ public void setGroupingStrategy(GroupingStrategy groupingStrategy) {
+ this.grouping_strategy = groupingStrategy;
+ }
+ }
+
+ /**
+ * Required check for a branch rule.
+ */
+ public static class RequiredCheck {
+ private String context;
+
+ /**
+ * Creates a required check instance.
+ */
+ public RequiredCheck() {
+ }
+
+ /**
+ * Gets the check context.
+ *
+ * @return the check context
+ */
+ public String getContext() {
+ return context;
+ }
+
+ /**
+ * Sets the check context.
+ *
+ * @param context
+ * the check context
+ */
+ public void setContext(String context) {
+ this.context = context;
+ }
+ }
+
+ /**
+ * Merge method for merge queue rules.
+ */
+ public enum MergeMethod {
+ /** Merge commit method. */
+ MERGE,
+ /** Squash merge method. */
+ SQUASH,
+ /** Rebase merge method. */
+ REBASE
+ }
+
+ /**
+ * Grouping strategy for merge queue rules.
+ */
+ public enum GroupingStrategy {
+ /** All entries must be green. */
+ ALLGREEN,
+ /** Head entry must be green. */
+ HEADGREEN
+ }
}
diff --git a/src/main/java/org/kohsuke/github/GitHubClient.java b/src/main/java/org/kohsuke/github/GitHubClient.java
index 726be44a33..50df18a068 100644
--- a/src/main/java/org/kohsuke/github/GitHubClient.java
+++ b/src/main/java/org/kohsuke/github/GitHubClient.java
@@ -90,7 +90,7 @@ class GitHubClient {
MAPPER.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
MAPPER.configure(DeserializationFeature.READ_UNKNOWN_ENUM_VALUES_USING_DEFAULT_VALUE, true);
MAPPER.configure(MapperFeature.ACCEPT_CASE_INSENSITIVE_ENUMS, true);
- MAPPER.setPropertyNamingStrategy(PropertyNamingStrategy.SNAKE_CASE);
+ MAPPER.setPropertyNamingStrategy(PropertyNamingStrategies.SNAKE_CASE);
}
/**
diff --git a/src/main/resources/META-INF/native-image/org.kohsuke/github-api/reflect-config.json b/src/main/resources/META-INF/native-image/org.kohsuke/github-api/reflect-config.json
index bf579ed21e..1a1a9f5cd1 100644
--- a/src/main/resources/META-INF/native-image/org.kohsuke/github-api/reflect-config.json
+++ b/src/main/resources/META-INF/native-image/org.kohsuke/github-api/reflect-config.json
@@ -4229,6 +4229,21 @@
"allPublicClasses": true,
"allDeclaredClasses": true
},
+ {
+ "name": "org.kohsuke.github.GHPullRequestCommitDetail$GHCommitDetailAuthor",
+ "allPublicFields": true,
+ "allDeclaredFields": true,
+ "queryAllPublicConstructors": true,
+ "queryAllDeclaredConstructors": true,
+ "allPublicConstructors": true,
+ "allDeclaredConstructors": true,
+ "queryAllPublicMethods": true,
+ "queryAllDeclaredMethods": true,
+ "allPublicMethods": true,
+ "allDeclaredMethods": true,
+ "allPublicClasses": true,
+ "allDeclaredClasses": true
+ },
{
"name": "org.kohsuke.github.GHPullRequestCommitDetail$Commit",
"allPublicFields": true,
@@ -5354,6 +5369,21 @@
"allPublicClasses": true,
"allDeclaredClasses": true
},
+ {
+ "name": "org.kohsuke.github.GHEnvironmentVariable",
+ "allPublicFields": true,
+ "allDeclaredFields": true,
+ "queryAllPublicConstructors": true,
+ "queryAllDeclaredConstructors": true,
+ "allPublicConstructors": true,
+ "allDeclaredConstructors": true,
+ "queryAllPublicMethods": true,
+ "queryAllDeclaredMethods": true,
+ "allPublicMethods": true,
+ "allDeclaredMethods": true,
+ "allPublicClasses": true,
+ "allDeclaredClasses": true
+ },
{
"name": "org.kohsuke.github.GHRepositoryVariable",
"allPublicFields": true,
@@ -5474,6 +5504,96 @@
"allPublicClasses": true,
"allDeclaredClasses": true
},
+ {
+ "name": "org.kohsuke.github.GHRule",
+ "allPublicFields": true,
+ "allDeclaredFields": true,
+ "queryAllPublicConstructors": true,
+ "queryAllDeclaredConstructors": true,
+ "allPublicConstructors": true,
+ "allDeclaredConstructors": true,
+ "queryAllPublicMethods": true,
+ "queryAllDeclaredMethods": true,
+ "allPublicMethods": true,
+ "allDeclaredMethods": true,
+ "allPublicClasses": true,
+ "allDeclaredClasses": true
+ },
+ {
+ "name": "org.kohsuke.github.GHRule$GroupingStrategy",
+ "allPublicFields": true,
+ "allDeclaredFields": true,
+ "queryAllPublicConstructors": true,
+ "queryAllDeclaredConstructors": true,
+ "allPublicConstructors": true,
+ "allDeclaredConstructors": true,
+ "queryAllPublicMethods": true,
+ "queryAllDeclaredMethods": true,
+ "allPublicMethods": true,
+ "allDeclaredMethods": true,
+ "allPublicClasses": true,
+ "allDeclaredClasses": true
+ },
+ {
+ "name": "org.kohsuke.github.GHRule$MergeMethod",
+ "allPublicFields": true,
+ "allDeclaredFields": true,
+ "queryAllPublicConstructors": true,
+ "queryAllDeclaredConstructors": true,
+ "allPublicConstructors": true,
+ "allDeclaredConstructors": true,
+ "queryAllPublicMethods": true,
+ "queryAllDeclaredMethods": true,
+ "allPublicMethods": true,
+ "allDeclaredMethods": true,
+ "allPublicClasses": true,
+ "allDeclaredClasses": true
+ },
+ {
+ "name": "org.kohsuke.github.GHRule$Parameters",
+ "allPublicFields": true,
+ "allDeclaredFields": true,
+ "queryAllPublicConstructors": true,
+ "queryAllDeclaredConstructors": true,
+ "allPublicConstructors": true,
+ "allDeclaredConstructors": true,
+ "queryAllPublicMethods": true,
+ "queryAllDeclaredMethods": true,
+ "allPublicMethods": true,
+ "allDeclaredMethods": true,
+ "allPublicClasses": true,
+ "allDeclaredClasses": true
+ },
+ {
+ "name": "org.kohsuke.github.GHRule$RequiredCheck",
+ "allPublicFields": true,
+ "allDeclaredFields": true,
+ "queryAllPublicConstructors": true,
+ "queryAllDeclaredConstructors": true,
+ "allPublicConstructors": true,
+ "allDeclaredConstructors": true,
+ "queryAllPublicMethods": true,
+ "queryAllDeclaredMethods": true,
+ "allPublicMethods": true,
+ "allDeclaredMethods": true,
+ "allPublicClasses": true,
+ "allDeclaredClasses": true
+ },
+ {
+ "name": "org.kohsuke.github.GHRule$RuleType",
+ "allPublicFields": true,
+ "allDeclaredFields": true,
+ "queryAllPublicConstructors": true,
+ "queryAllDeclaredConstructors": true,
+ "allPublicConstructors": true,
+ "allDeclaredConstructors": true,
+ "queryAllPublicMethods": true,
+ "queryAllDeclaredMethods": true,
+ "allPublicMethods": true,
+ "allDeclaredMethods": true,
+ "allPublicClasses": true,
+ "allDeclaredClasses": true
+ },
{
"name": "org.kohsuke.github.GHSearchBuilder",
"allPublicFields": true,
diff --git a/src/main/resources/META-INF/native-image/org.kohsuke/github-api/serialization-config.json b/src/main/resources/META-INF/native-image/org.kohsuke/github-api/serialization-config.json
index ffe3790ded..6b88237b8c 100644
--- a/src/main/resources/META-INF/native-image/org.kohsuke/github-api/serialization-config.json
+++ b/src/main/resources/META-INF/native-image/org.kohsuke/github-api/serialization-config.json
@@ -848,6 +848,9 @@
{
"name": "org.kohsuke.github.GHPullRequestCommitDetail"
},
+ {
+ "name": "org.kohsuke.github.GHPullRequestCommitDetail$GHCommitDetailAuthor"
+ },
{
"name": "org.kohsuke.github.GHPullRequestCommitDetail$Commit"
},
@@ -1073,6 +1076,9 @@
{
"name": "org.kohsuke.github.GHRepositoryTrafficTopReferralSources"
},
+ {
+ "name": "org.kohsuke.github.GHEnvironmentVariable"
+ },
{
"name": "org.kohsuke.github.GHRepositoryVariable$1"
},
@@ -1097,6 +1103,24 @@
{
"name": "org.kohsuke.github.GHRequestedAction"
},
+ {
+ "name": "org.kohsuke.github.GHRule"
+ },
+ {
+ "name": "org.kohsuke.github.GHRule$GroupingStrategy"
+ },
+ {
+ "name": "org.kohsuke.github.GHRule$MergeMethod"
+ },
+ {
+ "name": "org.kohsuke.github.GHRule$Parameters"
+ },
+ {
+ "name": "org.kohsuke.github.GHRule$RequiredCheck"
+ },
+ {
+ "name": "org.kohsuke.github.GHRule$RuleType"
+ },
{
"name": "org.kohsuke.github.GHSearchBuilder"
},
diff --git a/src/test/java/org/kohsuke/github/EnumTest.java b/src/test/java/org/kohsuke/github/EnumTest.java
index 8458561428..bbc8ad4e76 100644
--- a/src/test/java/org/kohsuke/github/EnumTest.java
+++ b/src/test/java/org/kohsuke/github/EnumTest.java
@@ -100,7 +100,7 @@ public void touchEnums() {
assertThat(GHPullRequestReviewState.APPROVED.action(), equalTo(GHPullRequestReviewEvent.APPROVE.action()));
assertThat(GHPullRequestReviewState.DISMISSED.toEvent(), nullValue());
- assertThat(GHPullRequestSearchBuilder.Sort.values().length, equalTo(4));
+ assertThat(GHPullRequestSearchBuilder.Sort.values().length, equalTo(6));
assertThat(GHReleaseBuilder.MakeLatest.values().length, equalTo(3));
diff --git a/src/test/java/org/kohsuke/github/GHEnvironmentVariableTest.java b/src/test/java/org/kohsuke/github/GHEnvironmentVariableTest.java
new file mode 100644
index 0000000000..cdc9bafbb6
--- /dev/null
+++ b/src/test/java/org/kohsuke/github/GHEnvironmentVariableTest.java
@@ -0,0 +1,36 @@
+package org.kohsuke.github;
+
+import org.junit.Test;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.is;
+
+/**
+ * Test class for GHEnvironmentVariable.
+ */
+public class GHEnvironmentVariableTest {
+
+ /**
+ * Create default GHEnvironmentVariableTest instance.
+ */
+ public GHEnvironmentVariableTest() {
+ }
+
+ /**
+ * Tests environment variable getters and setters.
+ */
+ @Test
+ public void testAccessors() {
+ GHEnvironmentVariable variable = new GHEnvironmentVariable();
+
+ variable.setName("name");
+ variable.setValue("value");
+ variable.setCreatedAt("created");
+ variable.setUpdatedAt("updated");
+
+ assertThat(variable.getName(), is("name"));
+ assertThat(variable.getValue(), is("value"));
+ assertThat(variable.getCreatedAt(), is("created"));
+ assertThat(variable.getUpdatedAt(), is("updated"));
+ }
+}
diff --git a/src/test/java/org/kohsuke/github/GHRuleTest.java b/src/test/java/org/kohsuke/github/GHRuleTest.java
new file mode 100644
index 0000000000..d1df4ec5ad
--- /dev/null
+++ b/src/test/java/org/kohsuke/github/GHRuleTest.java
@@ -0,0 +1,89 @@
+package org.kohsuke.github;
+
+import org.junit.Test;
+
+import java.util.Collections;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.is;
+import static org.hamcrest.Matchers.notNullValue;
+import static org.hamcrest.Matchers.sameInstance;
+
+/**
+ * Test class for GHRule.
+ */
+public class GHRuleTest {
+
+ /**
+ * Create default GHRuleTest instance.
+ */
+ public GHRuleTest() {
+ }
+
+ /**
+ * Tests rule getters and setters.
+ */
+ @Test
+ public void testRuleAccessors() {
+ GHRule rule = new GHRule();
+ GHRule.Parameters parameters = new GHRule.Parameters();
+
+ rule.setType(GHRule.RuleType.merge_queue);
+ rule.setParameters(parameters);
+
+ assertThat(rule.getType(), is(GHRule.RuleType.merge_queue));
+ assertThat(rule.getParameters(), is(sameInstance(parameters)));
+ assertThat(rule.wrap(), is(sameInstance(rule)));
+ }
+
+ /**
+ * Tests parameter getters and setters.
+ */
+ @Test
+ public void testParametersAccessors() {
+ GHRule.Parameters parameters = new GHRule.Parameters();
+ GHRule.RequiredCheck requiredCheck = new GHRule.RequiredCheck();
+
+ parameters.setRequiredStatusChecks(Collections.singleton(requiredCheck));
+ parameters.setMergeMethod(GHRule.MergeMethod.SQUASH);
+ parameters.setMaxEntriesToBuild(1);
+ parameters.setMinEntriesToMerge(2);
+ parameters.setMaxEntriesToMerge(3);
+ parameters.setMinEntriesToMergeWaitMinutes(4);
+ parameters.setCheckResponseTimeoutMinutes(5);
+ parameters.setGroupingStrategy(GHRule.GroupingStrategy.HEADGREEN);
+
+ assertThat(parameters.getRequiredStatusChecks(), is(equalTo(Collections.singleton(requiredCheck))));
+ assertThat(parameters.getMergeMethod(), is(GHRule.MergeMethod.SQUASH));
+ assertThat(parameters.getMaxEntriesToBuild(), is(1));
+ assertThat(parameters.getMinEntriesToMerge(), is(2));
+ assertThat(parameters.getMaxEntriesToMerge(), is(3));
+ assertThat(parameters.getMinEntriesToMergeWaitMinutes(), is(4));
+ assertThat(parameters.getCheckResponseTimeoutMinutes(), is(5));
+ assertThat(parameters.getGroupingStrategy(), is(GHRule.GroupingStrategy.HEADGREEN));
+ }
+
+ /**
+ * Tests required check accessors.
+ */
+ @Test
+ public void testRequiredCheckAccessors() {
+ GHRule.RequiredCheck requiredCheck = new GHRule.RequiredCheck();
+
+ requiredCheck.setContext("build");
+
+ assertThat(requiredCheck.getContext(), is("build"));
+ }
+
+ /**
+ * Tests rule enums.
+ */
+ @Test
+ public void testEnums() {
+ assertThat(GHRule.RuleType.values().length, is(14));
+ assertThat(GHRule.RuleType.unknown, is(notNullValue()));
+ assertThat(GHRule.MergeMethod.values().length, is(3));
+ assertThat(GHRule.GroupingStrategy.values().length, is(2));
+ }
+}