Skip to content

Commit 2b97817

Browse files
committed
Merge tag 'github-api-2.0-rc.4' into release/v2.x
github-api-2.0-rc.4
2 parents dc897ca + 4bc7ad2 commit 2b97817

File tree

282 files changed

+29204
-29180
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

282 files changed

+29204
-29180
lines changed

.github/workflows/create_release_tag_and_pr.yml

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,37 +21,39 @@ jobs:
2121
distribution: 'temurin'
2222
cache: 'maven'
2323

24-
- name: Reset staging/main
24+
- name: Reset staging
2525
id: staging
2626
run: |
27-
git checkout -B staging/main
28-
git push --set-upstream -f origin staging/main
27+
git checkout -B staging/$GITHUB_REF_NAME
28+
git push --set-upstream -f origin staging/$GITHUB_REF_NAME
29+
env:
30+
GITHUB_REF_NAME: ${{ github.ref_name }}
2931

3032
- name: Set Release Version
3133
id: release
3234
run: |
3335
mvn -B versions:set versions:commit -DremoveSnapshot
3436
echo "version=$(mvn -B help:evaluate -Dexpression=project.version -q -DforceStdout)" >> $GITHUB_OUTPUT
3537
36-
- uses: stefanzweifel/git-auto-commit-action@v5
38+
- uses: stefanzweifel/git-auto-commit-action@v6
3739
with:
3840
commit_message: "Prepare release (${{ github.actor }}): github-api-${{ steps.release.outputs.version }}"
3941
tagging_message: 'github-api-${{ steps.release.outputs.version }}'
40-
branch: staging/main
42+
branch: staging/${{ github.ref_name }}
4143

4244
- name: Increment Snapshot Version
4345
run: |
4446
mvn versions:set versions:commit -DnextSnapshot
4547
46-
- uses: stefanzweifel/git-auto-commit-action@v5
48+
- uses: stefanzweifel/git-auto-commit-action@v6
4749
with:
4850
commit_message: "Prepare for next development iteration"
49-
branch: staging/main
51+
branch: staging/${{ github.ref_name }}
5052

51-
- name: pull-request to main
53+
- name: Create pull-request
5254
uses: repo-sync/pull-request@v2
5355
with:
5456
pr_title: "Prepare release (${{ github.actor }}): github-api-${{ steps.release.outputs.version }}"
55-
source_branch: "staging/main"
56-
destination_branch: "main"
57+
source_branch: "staging/${{ github.ref_name }}"
58+
destination_branch: "${{ github.ref_name }}"
5759
github_token: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/maven-build.yml

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ jobs:
3535
- name: Maven Install (skipTests)
3636
env:
3737
MAVEN_OPTS: ${{ env.JAVA_11_PLUS_MAVEN_OPTS }}
38-
run: mvn -B clean install -Djapicmp.skip=true -DskipTests --file pom.xml
38+
run: mvn -B clean install -DskipTests --file pom.xml
3939
- uses: actions/upload-artifact@v4
4040
with:
4141
name: maven-target-directory
@@ -59,7 +59,7 @@ jobs:
5959
MAVEN_OPTS: ${{ env.JAVA_11_PLUS_MAVEN_OPTS }}
6060
# running install site seems to more closely imitate real site deployment,
6161
# more likely to prevent failed deployment
62-
run: mvn -B clean install site -Djapicmp.skip=true -DskipTests --file pom.xml
62+
run: mvn -B clean install site -DskipTests --file pom.xml
6363
test-bridged:
6464
name: build-and-test Bridged (Java 17)
6565
# Does not require build output, but orders execution to prevent launching test workflows when simple build fails
@@ -78,8 +78,7 @@ jobs:
7878
- name: Maven Install (skipTests)
7979
env:
8080
MAVEN_OPTS: ${{ env.JAVA_11_PLUS_MAVEN_OPTS }}
81-
#skipping japicmp check for bridged artifact until after next release
82-
run: mvn -B clean install -Djapicmp.skip=true -Pbridged -D enable-ci --file pom.xml "-Dsurefire.argLine=--add-opens java.base/java.net=ALL-UNNAMED"
81+
run: mvn -B clean install -Pbridged -D enable-ci --file pom.xml "-Dsurefire.argLine=--add-opens java.base/java.net=ALL-UNNAMED"
8382
test:
8483
name: test (${{ matrix.os }}, Java ${{ matrix.java }})
8584
# Does not require build output, but orders execution to prevent launching test workflows when simple build fails
@@ -108,8 +107,7 @@ jobs:
108107
if: matrix.os != 'windows'
109108
env:
110109
MAVEN_OPTS: ${{ env.JAVA_11_PLUS_MAVEN_OPTS }}
111-
# Disable japicmp until next release
112-
run: mvn -B clean install -Djapicmp.skip=true -D enable-ci --file pom.xml "-Dsurefire.argLine=--add-opens java.base/java.net=ALL-UNNAMED"
110+
run: mvn -B clean install -D enable-ci --file pom.xml "-Dsurefire.argLine=--add-opens java.base/java.net=ALL-UNNAMED"
113111
- name: Save coverage data
114112
if: matrix.os == 'ubuntu' && matrix.java == '17'
115113
uses: actions/upload-artifact@v4
@@ -128,7 +126,7 @@ jobs:
128126
name: maven-test-target-directory
129127
path: target
130128
- name: Codecov Report
131-
uses: codecov/[email protected].0
129+
uses: codecov/[email protected].3
132130
with:
133131
# Codecov token from https://app.codecov.io/gh/hub4j/github-api/settings
134132
token: ${{ secrets.CODECOV_TOKEN }}

.github/workflows/publish_release_branch.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
- name: Maven Install and Site with Code Coverage
2424
env:
2525
MAVEN_OPTS: ${{ env.JAVA_11_PLUS_MAVEN_OPTS }}
26-
run: mvn -B clean install site -Djapicmp.skip=true -D enable-ci --file pom.xml "-Dsurefire.argLine=--add-opens java.base/java.net=ALL-UNNAMED"
26+
run: mvn -B clean install site -D enable-ci --file pom.xml "-Dsurefire.argLine=--add-opens java.base/java.net=ALL-UNNAMED"
2727

2828
- uses: actions/upload-artifact@v4
2929
with:
@@ -49,15 +49,15 @@ jobs:
4949
gpg-passphrase: MAVEN_GPG_PASSPHRASE
5050

5151
- name: Publish package
52-
run: mvn -B clean deploy -Djapicmp.skip=true -DskipTests -Prelease
52+
run: mvn -B clean deploy -DskipTests -Prelease
5353
env:
5454
MAVEN_OPTS: ${{ env.JAVA_11_PLUS_MAVEN_OPTS }}
5555
MAVEN_USERNAME: ${{ secrets.OSSRH_TOKEN_USERNAME }}
5656
MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN_PASSWORD }}
5757
MAVEN_GPG_PASSPHRASE: ${{ secrets.OSSRH_GPG_SECRET_KEY_PASSPHRASE }}
5858

5959
- name: Publish package with bridge methods
60-
run: mvn -B clean deploy -Djapicmp.skip=true -DskipTests -Prelease -Pbridged
60+
run: mvn -B clean deploy -DskipTests -Prelease -Pbridged
6161
env:
6262
MAVEN_OPTS: ${{ env.JAVA_11_PLUS_MAVEN_OPTS }}
6363
MAVEN_USERNAME: ${{ secrets.OSSRH_TOKEN_USERNAME }}
@@ -90,7 +90,7 @@ jobs:
9090
cp -r ./target/site/* ./
9191
9292
- name: Publish GH Pages
93-
uses: stefanzweifel/git-auto-commit-action@v5
93+
uses: stefanzweifel/git-auto-commit-action@v6
9494
with:
9595
commit_message: "Release (${{ github.actor }}): v${{ steps.release.outputs.version }}"
9696
branch: gh-pages

pom.xml

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<modelVersion>4.0.0</modelVersion>
44
<groupId>org.kohsuke</groupId>
55
<artifactId>${github-api.artifactId}</artifactId>
6-
<version>2.0-rc.3</version>
6+
<version>2.0-rc.4</version>
77
<name>GitHub API for Java</name>
88
<description>GitHub API for Java</description>
99
<url>https://hub4j.github.io/github-api/</url>
@@ -73,7 +73,7 @@
7373
<jacoco.surefire.argLine></jacoco.surefire.argLine>
7474
<jjwt.suite.version>0.12.6</jjwt.suite.version>
7575
<!-- This project was registered before 2021, so it uses the old server. -->
76-
<nexus.serverUrl>https://oss.sonatype.org</nexus.serverUrl>
76+
<nexus.serverUrl>https://ossrh-staging-api.central.sonatype.com</nexus.serverUrl>
7777
<okhttp3.version>4.12.0</okhttp3.version>
7878
<okio.version>3.10.2</okio.version>
7979
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
@@ -89,7 +89,7 @@
8989
<dependency>
9090
<groupId>com.fasterxml.jackson</groupId>
9191
<artifactId>jackson-bom</artifactId>
92-
<version>2.18.3</version>
92+
<version>2.19.1</version>
9393
<type>pom</type>
9494
<scope>import</scope>
9595
</dependency>
@@ -146,11 +146,15 @@
146146
<groupId>com.fasterxml.jackson.datatype</groupId>
147147
<artifactId>jackson-datatype-jsr310</artifactId>
148148
</dependency>
149+
<dependency>
150+
<groupId>com.github.spotbugs</groupId>
151+
<artifactId>spotbugs-annotations</artifactId>
152+
<version>${spotbugs.version}</version>
153+
</dependency>
149154
<dependency>
150155
<groupId>com.infradna.tool</groupId>
151156
<artifactId>bridge-method-annotation</artifactId>
152-
<version>1.30</version>
153-
<optional>true</optional>
157+
<version>1.31</version>
154158
</dependency>
155159
<dependency>
156160
<groupId>com.squareup.okhttp3</groupId>
@@ -190,13 +194,7 @@
190194
<dependency>
191195
<groupId>org.apache.commons</groupId>
192196
<artifactId>commons-lang3</artifactId>
193-
<version>3.17.0</version>
194-
</dependency>
195-
<dependency>
196-
<groupId>com.github.spotbugs</groupId>
197-
<artifactId>spotbugs-annotations</artifactId>
198-
<version>${spotbugs.version}</version>
199-
<scope>provided</scope>
197+
<version>3.18.0</version>
200198
</dependency>
201199
<dependency>
202200
<groupId>com.github.npathai</groupId>
@@ -310,7 +308,7 @@
310308
<plugin>
311309
<groupId>com.infradna.tool</groupId>
312310
<artifactId>bridge-method-injector</artifactId>
313-
<version>1.30</version>
311+
<version>1.31</version>
314312
<executions>
315313
<execution>
316314
<goals>
@@ -475,7 +473,7 @@
475473
<plugin>
476474
<groupId>com.diffplug.spotless</groupId>
477475
<artifactId>spotless-maven-plugin</artifactId>
478-
<version>2.44.3</version>
476+
<version>2.44.5</version>
479477
<configuration>
480478
<java>
481479
<includes>
@@ -484,13 +482,19 @@
484482
</includes>
485483

486484
<eclipse>
485+
<version>4.35</version>
487486
<file>${basedir}/src/build/eclipse/formatter.xml</file>
487+
<sortMembersEnabled>true</sortMembersEnabled>
488+
<sortMembersVisibilityOrderEnabled>true</sortMembersVisibilityOrderEnabled>
489+
<sortMembersDoNotSortFields>false</sortMembersDoNotSortFields>
488490
</eclipse>
489491

490492
<importOrder>
491493
<file>${basedir}/src/build/eclipse/eclipse.importorder</file>
492494
</importOrder>
495+
493496
<removeUnusedImports></removeUnusedImports>
497+
<formatAnnotations></formatAnnotations>
494498

495499
<trimTrailingWhitespace></trimTrailingWhitespace>
496500
<endWithNewline></endWithNewline>

src/main/java/org/kohsuke/github/AbstractBuilder.java

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,13 @@
4343
*/
4444
abstract class AbstractBuilder<R, S> extends GitHubInteractiveObject implements GitHubRequestBuilderDone<R> {
4545

46-
@Nonnull
47-
private final Class<R> returnType;
46+
@CheckForNull
47+
private final R baseInstance;
4848

4949
private final boolean commitChangesImmediately;
5050

51-
@CheckForNull
52-
private final R baseInstance;
51+
@Nonnull
52+
private final Class<R> returnType;
5353

5454
/** The requester. */
5555
@Nonnull
@@ -111,54 +111,54 @@ public R done() throws IOException {
111111
}
112112

113113
/**
114-
* Applies a value to a name for this builder.
114+
* Chooses whether to return a continuing builder or an updated data record
115115
*
116116
* If {@code S} is the same as {@code R}, this method will commit changes after the first value change and return a
117117
* {@code R} from {@link #done()}.
118118
*
119119
* If {@code S} is not the same as {@code R}, this method will return an {@code S} and letting the caller batch
120120
* together multiple changes and call {@link #done()} when they are ready.
121121
*
122-
* @param name
123-
* the name of the field
124-
* @param value
125-
* the value of the field
126122
* @return either a continuing builder or an updated data record
127123
* @throws IOException
128124
* if an I/O error occurs
129125
*/
130126
@Nonnull
131127
@BetaApi
132-
protected S with(@Nonnull String name, Object value) throws IOException {
133-
requester.with(name, value);
134-
return continueOrDone();
128+
protected S continueOrDone() throws IOException {
129+
// This little bit of roughness in this base class means all inheriting builders get to create Updater and
130+
// Setter classes from almost identical code. Creator can often be implemented with significant code reuse as
131+
// well.
132+
if (commitChangesImmediately) {
133+
// These casts look strange and risky, but they they're actually guaranteed safe due to the return path
134+
// being based on the previous comparison of class instances passed to the constructor.
135+
return (S) done();
136+
} else {
137+
return (S) this;
138+
}
135139
}
136140

137141
/**
138-
* Chooses whether to return a continuing builder or an updated data record
142+
* Applies a value to a name for this builder.
139143
*
140144
* If {@code S} is the same as {@code R}, this method will commit changes after the first value change and return a
141145
* {@code R} from {@link #done()}.
142146
*
143147
* If {@code S} is not the same as {@code R}, this method will return an {@code S} and letting the caller batch
144148
* together multiple changes and call {@link #done()} when they are ready.
145149
*
150+
* @param name
151+
* the name of the field
152+
* @param value
153+
* the value of the field
146154
* @return either a continuing builder or an updated data record
147155
* @throws IOException
148156
* if an I/O error occurs
149157
*/
150158
@Nonnull
151159
@BetaApi
152-
protected S continueOrDone() throws IOException {
153-
// This little bit of roughness in this base class means all inheriting builders get to create Updater and
154-
// Setter classes from almost identical code. Creator can often be implemented with significant code reuse as
155-
// well.
156-
if (commitChangesImmediately) {
157-
// These casts look strange and risky, but they they're actually guaranteed safe due to the return path
158-
// being based on the previous comparison of class instances passed to the constructor.
159-
return (S) done();
160-
} else {
161-
return (S) this;
162-
}
160+
protected S with(@Nonnull String name, Object value) throws IOException {
161+
requester.with(name, value);
162+
return continueOrDone();
163163
}
164164
}

src/main/java/org/kohsuke/github/EnterpriseManagedSupport.java

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,38 @@
1414
*/
1515
class EnterpriseManagedSupport {
1616

17+
private static final Logger LOGGER = Logger.getLogger(EnterpriseManagedSupport.class.getName());
1718
static final String COULD_NOT_RETRIEVE_ORGANIZATION_EXTERNAL_GROUPS = "Could not retrieve organization external groups";
1819
static final String NOT_PART_OF_EXTERNALLY_MANAGED_ENTERPRISE_ERROR = "This organization is not part of externally managed enterprise.";
20+
1921
static final String TEAM_CANNOT_BE_EXTERNALLY_MANAGED_ERROR = "This team cannot be externally managed since it has explicit members.";
2022

21-
private static final Logger LOGGER = Logger.getLogger(EnterpriseManagedSupport.class.getName());
23+
private static String logUnexpectedFailure(final JsonProcessingException exception, final String payload) {
24+
final StringWriter sw = new StringWriter();
25+
final PrintWriter pw = new PrintWriter(sw);
26+
exception.printStackTrace(pw);
27+
return String.format("Could not parse GitHub error response: '%s'. Full stacktrace follows:%n%s", payload, sw);
28+
}
29+
30+
static EnterpriseManagedSupport forOrganization(final GHOrganization org) {
31+
return new EnterpriseManagedSupport(org);
32+
}
2233

2334
private final GHOrganization organization;
2435

2536
private EnterpriseManagedSupport(GHOrganization organization) {
2637
this.organization = organization;
2738
}
2839

40+
Optional<GHException> filterException(final GHException e) {
41+
if (e.getCause() instanceof HttpException) {
42+
final HttpException he = (HttpException) e.getCause();
43+
return filterException(he, COULD_NOT_RETRIEVE_ORGANIZATION_EXTERNAL_GROUPS)
44+
.map(translated -> new GHException(COULD_NOT_RETRIEVE_ORGANIZATION_EXTERNAL_GROUPS, translated));
45+
}
46+
return Optional.empty();
47+
}
48+
2949
Optional<GHIOException> filterException(final HttpException he, final String scenario) {
3050
if (he.getResponseCode() == 400) {
3151
final String responseMessage = he.getMessage();
@@ -46,24 +66,4 @@ Optional<GHIOException> filterException(final HttpException he, final String sce
4666
return Optional.empty();
4767
}
4868

49-
Optional<GHException> filterException(final GHException e) {
50-
if (e.getCause() instanceof HttpException) {
51-
final HttpException he = (HttpException) e.getCause();
52-
return filterException(he, COULD_NOT_RETRIEVE_ORGANIZATION_EXTERNAL_GROUPS)
53-
.map(translated -> new GHException(COULD_NOT_RETRIEVE_ORGANIZATION_EXTERNAL_GROUPS, translated));
54-
}
55-
return Optional.empty();
56-
}
57-
58-
static EnterpriseManagedSupport forOrganization(final GHOrganization org) {
59-
return new EnterpriseManagedSupport(org);
60-
}
61-
62-
private static String logUnexpectedFailure(final JsonProcessingException exception, final String payload) {
63-
final StringWriter sw = new StringWriter();
64-
final PrintWriter pw = new PrintWriter(sw);
65-
exception.printStackTrace(pw);
66-
return String.format("Could not parse GitHub error response: '%s'. Full stacktrace follows:%n%s", payload, sw);
67-
}
68-
6969
}

0 commit comments

Comments
 (0)