Skip to content

Commit 54d8fe9

Browse files
authored
Merge branch 'main' into check-run-enum
2 parents c00d562 + 4abf33a commit 54d8fe9

112 files changed

Lines changed: 2269 additions & 680 deletions

File tree

Some content is hidden

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

.github/workflows/maven-build.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
java-version: ${{ matrix.java }}
2323
distribution: 'adopt'
2424
- name: Cached .m2
25-
uses: actions/cache@v2.1.5
25+
uses: actions/cache@v2.1.6
2626
with:
2727
path: ~/.m2/repository
2828
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
@@ -46,7 +46,7 @@ jobs:
4646
with:
4747
java-version: ${{ matrix.java }}
4848
distribution: 'adopt'
49-
- uses: actions/cache@v2.1.5
49+
- uses: actions/cache@v2.1.6
5050
with:
5151
path: ~/.m2/repository
5252
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
@@ -69,7 +69,7 @@ jobs:
6969
with:
7070
java-version: ${{ matrix.java }}
7171
distribution: 'adopt'
72-
- uses: actions/cache@v2.1.5
72+
- uses: actions/cache@v2.1.6
7373
with:
7474
path: ~/.m2/repository
7575
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
@@ -90,9 +90,9 @@ jobs:
9090
if: matrix.os == 'windows' && matrix.java != '8'
9191
env:
9292
MAVEN_OPTS: ${{ env.JAVA_11_PLUS_MAVEN_OPTS }}
93-
run: mvn -B install --file pom.xml
93+
run: mvn -B install --file pom.xml "-Dsurefire.argLine=--add-opens java.base/java.net=ALL-UNNAMED"
9494
- name: Maven Install with Code Coverage
9595
if: matrix.os != 'windows' && matrix.java != '8'
9696
env:
9797
MAVEN_OPTS: ${{ env.JAVA_11_PLUS_MAVEN_OPTS }}
98-
run: mvn -B install -D enable-ci --file pom.xml
98+
run: mvn -B install -D enable-ci --file pom.xml "-Dsurefire.argLine=--add-opens java.base/java.net=ALL-UNNAMED"

pom.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@
323323
<plugin>
324324
<groupId>com.diffplug.spotless</groupId>
325325
<artifactId>spotless-maven-plugin</artifactId>
326-
<version>2.10.3</version>
326+
<version>2.11.1</version>
327327
<executions>
328328
<execution>
329329
<id>spotless-check</id>
@@ -389,7 +389,7 @@
389389
<dependency>
390390
<groupId>com.tngtech.archunit</groupId>
391391
<artifactId>archunit</artifactId>
392-
<version>0.18.0</version>
392+
<version>0.19.0</version>
393393
<scope>test</scope>
394394
</dependency>
395395
<dependency>
@@ -420,7 +420,7 @@
420420
<dependency>
421421
<groupId>org.awaitility</groupId>
422422
<artifactId>awaitility</artifactId>
423-
<version>4.0.3</version>
423+
<version>4.1.0</version>
424424
<scope>test</scope>
425425
</dependency>
426426
<dependency>
@@ -537,7 +537,7 @@
537537
<dependency>
538538
<groupId>com.github.tomakehurst</groupId>
539539
<artifactId>wiremock-jre8-standalone</artifactId>
540-
<version>2.27.2</version>
540+
<version>2.28.0</version>
541541
<scope>test</scope>
542542
</dependency>
543543
<dependency>

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

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ public class GHMeta {
2323
private List<String> api;
2424
private List<String> pages;
2525
private List<String> importer = new ArrayList<>();
26+
private List<String> packages;
27+
private List<String> actions;
28+
private List<String> dependabot;
2629

2730
/**
2831
* Is verifiable password authentication boolean.
@@ -86,4 +89,31 @@ public List<String> getPages() {
8689
public List<String> getImporter() {
8790
return Collections.unmodifiableList(importer);
8891
}
92+
93+
/**
94+
* Gets package.
95+
*
96+
* @return the package
97+
*/
98+
public List<String> getPackages() {
99+
return Collections.unmodifiableList(packages);
100+
}
101+
102+
/**
103+
* Gets actions.
104+
*
105+
* @return the actions
106+
*/
107+
public List<String> getActions() {
108+
return Collections.unmodifiableList(actions);
109+
}
110+
111+
/**
112+
* Gets dependabot.
113+
*
114+
* @return the dependabot
115+
*/
116+
public List<String> getDependabot() {
117+
return Collections.unmodifiableList(dependabot);
118+
}
89119
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3073,7 +3073,7 @@ public GHArtifact getArtifact(long id) throws IOException {
30733073
*/
30743074
public GHWorkflowJob getWorkflowJob(long id) throws IOException {
30753075
return root.createRequest()
3076-
.withUrlPath(getApiTailUrl("/actions/jobs/"), String.valueOf(id))
3076+
.withUrlPath(getApiTailUrl("/actions/jobs"), String.valueOf(id))
30773077
.fetch(GHWorkflowJob.class)
30783078
.wrapUp(this);
30793079
}

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

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
import java.io.IOException;
77
import java.io.InputStream;
8+
import java.lang.reflect.Field;
89
import java.net.HttpURLConnection;
910
import java.net.ProtocolException;
1011
import java.nio.charset.StandardCharsets;
@@ -162,9 +163,30 @@ private static void setRequestMethod(String method, HttpURLConnection connection
162163
connection.setRequestMethod(method);
163164
} catch (ProtocolException e) {
164165
// JDK only allows one of the fixed set of verbs. Try to override that
165-
connection.setRequestProperty("X-HTTP-Method-Override", method);
166-
connection.setRequestMethod("POST");
166+
try {
167+
Field $method = HttpURLConnection.class.getDeclaredField("method");
168+
$method.setAccessible(true);
169+
$method.set(connection, method);
170+
} catch (Exception x) {
171+
throw (IOException) new IOException("Failed to set the custom verb").initCause(x);
172+
}
173+
// sun.net.www.protocol.https.DelegatingHttpsURLConnection delegates to another HttpURLConnection
174+
try {
175+
Field $delegate = connection.getClass().getDeclaredField("delegate");
176+
$delegate.setAccessible(true);
177+
Object delegate = $delegate.get(connection);
178+
if (delegate instanceof HttpURLConnection) {
179+
HttpURLConnection nested = (HttpURLConnection) delegate;
180+
setRequestMethod(method, nested);
181+
}
182+
} catch (NoSuchFieldException x) {
183+
// no problem
184+
} catch (IllegalAccessException x) {
185+
throw (IOException) new IOException("Failed to set the custom verb").initCause(x);
186+
}
167187
}
188+
if (!connection.getRequestMethod().equals(method))
189+
throw new IllegalStateException("Failed to set the request method to " + method);
168190
}
169191

170192
/**

src/test/java/org/kohsuke/github/GitHubTest.java

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -168,11 +168,14 @@ public void getMeta() throws IOException {
168168
GHMeta meta = gitHub.getMeta();
169169
assertThat(meta.isVerifiablePasswordAuthentication(), is(true));
170170
assertThat(meta.getApi().size(), equalTo(19));
171-
assertThat(meta.getGit().size(), equalTo(19));
172-
assertThat(meta.getHooks().size(), equalTo(3));
173-
assertThat(meta.getImporter().size(), equalTo(6));
171+
assertThat(meta.getGit().size(), equalTo(36));
172+
assertThat(meta.getHooks().size(), equalTo(4));
173+
assertThat(meta.getImporter().size(), equalTo(3));
174174
assertThat(meta.getPages().size(), equalTo(6));
175-
assertThat(meta.getWeb().size(), equalTo(19));
175+
assertThat(meta.getWeb().size(), equalTo(20));
176+
assertThat(meta.getPackages().size(), equalTo(25));
177+
assertThat(meta.getActions().size(), equalTo(1739));
178+
assertThat(meta.getDependabot().size(), equalTo(3));
176179

177180
// Also test examples here
178181
Class[] examples = new Class[]{ ReadOnlyObjects.GHMetaPublic.class, ReadOnlyObjects.GHMetaPackage.class,
@@ -185,11 +188,11 @@ public void getMeta() throws IOException {
185188
.fetch((Class<ReadOnlyObjects.GHMetaExample>) metaClass);
186189
assertThat(metaExample.isVerifiablePasswordAuthentication(), is(true));
187190
assertThat(metaExample.getApi().size(), equalTo(19));
188-
assertThat(metaExample.getGit().size(), equalTo(19));
189-
assertThat(metaExample.getHooks().size(), equalTo(3));
190-
assertThat(metaExample.getImporter().size(), equalTo(6));
191+
assertThat(metaExample.getGit().size(), equalTo(36));
192+
assertThat(metaExample.getHooks().size(), equalTo(4));
193+
assertThat(metaExample.getImporter().size(), equalTo(3));
191194
assertThat(metaExample.getPages().size(), equalTo(6));
192-
assertThat(metaExample.getWeb().size(), equalTo(19));
195+
assertThat(metaExample.getWeb().size(), equalTo(20));
193196
}
194197
}
195198

src/test/java/org/kohsuke/github/junit/GitHubWireMockRule.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -159,9 +159,6 @@ private void recordSnapshot(WireMockServer server, String target, boolean isRawS
159159
if (server != null) {
160160

161161
server.snapshotRecord(recordSpec().forTarget(target)
162-
// "X-HTTP-Method-Override" is used to send http methods not supported by
163-
// HttpURLConnection without using hacky Java reflection techniques
164-
.captureHeader("X-HTTP-Method-Override")
165162
// "If-None-Match" header used for ETag matching for caching connections
166163
.captureHeader("If-None-Match")
167164
// "If-Modified-Since" header used for ETag matching for caching connections

src/test/resources/org/kohsuke/github/AppTest/wiremock/notifications/mappings/notifications_threads_523050578-25.json

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,15 @@
33
"name": "notifications_threads_523050578",
44
"request": {
55
"url": "/notifications/threads/523050578",
6+
"method": "PATCH",
67
"bodyPatterns": [
78
{
89
"equalToJson": "{}",
910
"ignoreArrayOrder": true,
1011
"ignoreExtraElements": true
1112
}
1213
],
13-
"method": "POST",
1414
"headers": {
15-
"X-HTTP-Method-Override": {
16-
"equalTo": "PATCH"
17-
},
1815
"Accept": {
1916
"equalTo": "text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2"
2017
}

src/test/resources/org/kohsuke/github/AppTest/wiremock/testCreateCommitComment/mappings/repos_kohsuke_sandbox-ant_comments_46267761-7.json

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,8 @@
33
"name": "repos_kohsuke_sandbox-ant_comments_46267761",
44
"request": {
55
"url": "/repos/kohsuke/sandbox-ant/comments/46267761",
6-
"method": "POST",
6+
"method": "PATCH",
77
"headers": {
8-
"X-HTTP-Method-Override": {
9-
"equalTo": "PATCH"
10-
},
118
"Accept": {
129
"equalTo": "text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2"
1310
}

src/test/resources/org/kohsuke/github/AppTest/wiremock/testCreateIssue/mappings/repos_hub4j-test-org_github-api-test_issues_1-11.json

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,15 @@
33
"name": "repos_hub4j-test-org_github-api-test_issues_1",
44
"request": {
55
"url": "/repos/hub4j-test-org/github-api-test/issues/1",
6+
"method": "PATCH",
67
"bodyPatterns": [
78
{
89
"equalToJson": "{\"state\":\"closed\"}",
910
"ignoreArrayOrder": true,
1011
"ignoreExtraElements": true
1112
}
1213
],
13-
"method": "POST",
1414
"headers": {
15-
"X-HTTP-Method-Override": {
16-
"equalTo": "PATCH"
17-
},
1815
"Accept": {
1916
"equalTo": "text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2"
2017
}

0 commit comments

Comments
 (0)