Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 5888efc

Browse filesBrowse files
authored
Merge branch 'master' into add-preview-arch-rules
2 parents 459d1b4 + 9151102 commit 5888efc
Copy full SHA for 5888efc
Expand file treeCollapse file tree

24 files changed

+1560
-19
lines changed

‎CONTRIBUTING.md

Copy file name to clipboardExpand all lines: CONTRIBUTING.md
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ Example:
1414

1515
This the default behavior.
1616

17+
Example for a single test case:
18+
19+
`mvn install -Dtest=WireMockStatusReporterTest#user_whenProxying_AuthCorrectlyConfigured`
20+
1721

1822
### Setting up credential
1923

‎pom.xml

Copy file name to clipboardExpand all lines: pom.xml
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
<properties>
3535
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
3636
<spotbugs-maven-plugin.version>4.0.4</spotbugs-maven-plugin.version>
37-
<spotbugs.version>4.1.2</spotbugs.version>
37+
<spotbugs.version>4.1.3</spotbugs.version>
3838
<spotbugs-maven-plugin.failOnError>true</spotbugs-maven-plugin.failOnError>
3939
<hamcrest.version>2.2</hamcrest.version>
4040
<okhttp3.version>4.4.1</okhttp3.version>
@@ -261,7 +261,7 @@
261261
<plugin>
262262
<groupId>org.apache.maven.plugins</groupId>
263263
<artifactId>maven-project-info-reports-plugin</artifactId>
264-
<version>3.1.0</version>
264+
<version>3.1.1</version>
265265
<dependencies>
266266
<dependency>
267267
<groupId>org.apache.bcel</groupId>
@@ -543,7 +543,7 @@
543543
<dependency>
544544
<groupId>org.mockito</groupId>
545545
<artifactId>mockito-core</artifactId>
546-
<version>3.6.0</version>
546+
<version>3.6.28</version>
547547
<scope>test</scope>
548548
</dependency>
549549
<dependency>

‎src/main/java/org/kohsuke/github/GHEventPayload.java

Copy file name to clipboardExpand all lines: src/main/java/org/kohsuke/github/GHEventPayload.java
+10Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1216,6 +1216,7 @@ public static class Status extends GHEventPayload {
12161216
private String description;
12171217
private GHCommitState state;
12181218
private GHCommit commit;
1219+
private String targetUrl;
12191220

12201221
/**
12211222
* Gets the status content.
@@ -1226,6 +1227,15 @@ public String getContext() {
12261227
return context;
12271228
}
12281229

1230+
/**
1231+
* The optional link added to the status.
1232+
*
1233+
* @return a url
1234+
*/
1235+
public String getTargetUrl() {
1236+
return targetUrl;
1237+
}
1238+
12291239
/**
12301240
* Gets the status description.
12311241
*

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

Copy file name to clipboardExpand all lines: src/main/java/org/kohsuke/github/GHRepository.java
+48-3Lines changed: 48 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -818,6 +818,13 @@ public int getSize() {
818818
return size;
819819
}
820820

821+
/**
822+
* Affiliation of a repository collaborator
823+
*/
824+
public enum CollaboratorAffiliation {
825+
ALL, DIRECT, OUTSIDE
826+
}
827+
821828
/**
822829
* Gets the collaborators on this repository. This set always appear to include the owner.
823830
*
@@ -841,6 +848,19 @@ public PagedIterable<GHUser> listCollaborators() throws IOException {
841848
return listUsers("collaborators");
842849
}
843850

851+
/**
852+
* Lists up the collaborators on this repository.
853+
*
854+
* @param affiliation
855+
* Filter users by affiliation
856+
* @return Users paged iterable
857+
* @throws IOException
858+
* the io exception
859+
*/
860+
public PagedIterable<GHUser> listCollaborators(CollaboratorAffiliation affiliation) throws IOException {
861+
return listUsers(root.createRequest().with("affiliation", affiliation), "collaborators");
862+
}
863+
844864
/**
845865
* Lists all
846866
* <a href="https://help.github.com/articles/assigning-issues-and-pull-requests-to-other-github-users/">the
@@ -888,6 +908,29 @@ public Set<String> getCollaboratorNames() throws IOException {
888908
return r;
889909
}
890910

911+
/**
912+
* Gets the names of the collaborators on this repository. This method deviates from the principle of this library
913+
* but it works a lot faster than {@link #getCollaborators()}.
914+
*
915+
* @param affiliation
916+
* Filter users by affiliation
917+
* @return the collaborator names
918+
* @throws IOException
919+
* the io exception
920+
*/
921+
public Set<String> getCollaboratorNames(CollaboratorAffiliation affiliation) throws IOException {
922+
Set<String> r = new HashSet<>();
923+
// no initializer - we just want to the logins
924+
PagedIterable<GHUser> users = root.createRequest()
925+
.withUrlPath(getApiTailUrl("collaborators"))
926+
.with("affiliation", affiliation)
927+
.toIterable(GHUser[].class, null);
928+
for (GHUser u : users.toArray()) {
929+
r.add(u.login);
930+
}
931+
return r;
932+
}
933+
891934
/**
892935
* Obtain permission for a given user in this repository.
893936
*
@@ -2092,9 +2135,11 @@ public PagedIterable<GHStargazer> listStargazers2() {
20922135
}
20932136

20942137
private PagedIterable<GHUser> listUsers(final String suffix) {
2095-
return root.createRequest()
2096-
.withUrlPath(getApiTailUrl(suffix))
2097-
.toIterable(GHUser[].class, item -> item.wrapUp(root));
2138+
return listUsers(root.createRequest(), suffix);
2139+
}
2140+
2141+
private PagedIterable<GHUser> listUsers(Requester requester, final String suffix) {
2142+
return requester.withUrlPath(getApiTailUrl(suffix)).toIterable(GHUser[].class, item -> item.wrapUp(root));
20982143
}
20992144

21002145
/**

‎src/main/java/org/kohsuke/github/GitHubRequest.java

Copy file name to clipboardExpand all lines: src/main/java/org/kohsuke/github/GitHubRequest.java
+24-9Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ private GitHubRequest(@Nonnull List<Entry> args,
7575

7676
/**
7777
* Create a new {@link Builder}.
78-
*
78+
*
7979
* @return a new {@link Builder}.
8080
*/
8181
public static Builder<?> newBuilder() {
@@ -165,7 +165,7 @@ public Map<String, Object> injectedMappingValues() {
165165

166166
/**
167167
* The base GitHub API URL for this request represented as a {@link String}
168-
*
168+
*
169169
* @return the url string
170170
*/
171171
@Nonnull
@@ -176,7 +176,7 @@ public String apiUrl() {
176176
/**
177177
* The url path to be added to the {@link #apiUrl()} for this request. If this does not start with a "/", it instead
178178
* represents the full url string for this request.
179-
*
179+
*
180180
* @return a url path or full url string
181181
*/
182182
@Nonnull
@@ -186,7 +186,7 @@ public String urlPath() {
186186

187187
/**
188188
* The content type to to be sent by this request.
189-
*
189+
*
190190
* @return the content type.
191191
*/
192192
@Nonnull
@@ -196,7 +196,7 @@ public String contentType() {
196196

197197
/**
198198
* The {@link InputStream} to be sent as the body of this request.
199-
*
199+
*
200200
* @return the {@link InputStream}.
201201
*/
202202
@CheckForNull
@@ -206,7 +206,7 @@ public InputStream body() {
206206

207207
/**
208208
* The {@link URL} for this request. This is the actual URL the {@link GitHubClient} will send this request to.
209-
*
209+
*
210210
* @return the request {@link URL}
211211
*/
212212
@Nonnull
@@ -216,7 +216,7 @@ public URL url() {
216216

217217
/**
218218
* Whether arguments for this request should be included in the URL or in the body of the request.
219-
*
219+
*
220220
* @return true if the arguements should be sent in the body of the request.
221221
*/
222222
public boolean inBody() {
@@ -226,7 +226,7 @@ public boolean inBody() {
226226
/**
227227
* Create a {@link Builder} from this request. Initial values of the builder will be the same as this
228228
* {@link GitHubRequest}.
229-
*
229+
*
230230
* @return a {@link Builder} based on this request.
231231
*/
232232
public Builder<?> toBuilder() {
@@ -346,7 +346,7 @@ private Builder(@Nonnull List<Entry> args,
346346

347347
/**
348348
* Builds a {@link GitHubRequest} from this builder.
349-
*
349+
*
350350
* @return a {@link GitHubRequest}
351351
* @throws MalformedURLException
352352
* if the GitHub API URL cannot be constructed
@@ -437,6 +437,21 @@ public B withPreview(String name) {
437437
return withHeader("Accept", name);
438438
}
439439

440+
/**
441+
* With requester.
442+
*
443+
* @param Map
444+
* map of key value pairs to add
445+
* @return the request builder
446+
*/
447+
public B with(Map<String, Object> map) {
448+
for (Map.Entry<String, Object> entry : map.entrySet()) {
449+
with(entry.getKey(), entry.getValue());
450+
}
451+
452+
return (B) this;
453+
}
454+
440455
/**
441456
* With requester.
442457
*

‎src/main/java/org/kohsuke/github/extras/OkHttpConnector.java

Copy file name to clipboardExpand all lines: src/main/java/org/kohsuke/github/extras/OkHttpConnector.java
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,11 @@
2626
*
2727
* @author Roberto Tyley
2828
* @author Kohsuke Kawaguchi
29+
* @deprecated This class depends on an unsupported version of OkHttp. Switch to
30+
* {@link org.kohsuke.github.extras.okhttp3.OkHttpConnector}.
31+
* @see org.kohsuke.github.extras.okhttp3.OkHttpConnector
2932
*/
33+
@Deprecated
3034
public class OkHttpConnector implements HttpConnector {
3135
private static final String HEADER_NAME = "Cache-Control";
3236
private final OkUrlFactory urlFactory;

‎src/test/java/org/kohsuke/github/GHEventPayloadTest.java

Copy file name to clipboardExpand all lines: src/test/java/org/kohsuke/github/GHEventPayloadTest.java
+8Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -471,6 +471,14 @@ public void status() throws Exception {
471471
assertThat(event.getState(), is(GHCommitState.SUCCESS));
472472
assertThat(event.getCommit().getSHA1(), is("9049f1265b7d61be4a8904a9a27120d2064dab3b"));
473473
assertThat(event.getRepository().getOwner().getLogin(), is("baxterthehacker"));
474+
assertNull(event.getTargetUrl());
475+
}
476+
477+
@Test
478+
public void status2() throws Exception {
479+
GHEventPayload.Status event = GitHub.offline()
480+
.parseEventPayload(payload.asReader(), GHEventPayload.Status.class);
481+
assertThat(event.getTargetUrl(), is("https://www.wikipedia.org/"));
474482
}
475483

476484
// TODO implement support classes and write test

‎src/test/java/org/kohsuke/github/GHRepositoryTest.java

Copy file name to clipboardExpand all lines: src/test/java/org/kohsuke/github/GHRepositoryTest.java
+9Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -645,6 +645,15 @@ public void listCollaborators() throws Exception {
645645
assertThat(collaborators.size(), greaterThan(10));
646646
}
647647

648+
@Test
649+
public void listCollaboratorsFiltered() throws Exception {
650+
GHRepository repo = getRepository();
651+
List<GHUser> allCollaborators = repo.listCollaborators().toList();
652+
List<GHUser> filteredCollaborators = repo.listCollaborators(GHRepository.CollaboratorAffiliation.OUTSIDE)
653+
.toList();
654+
assertThat(filteredCollaborators.size(), lessThan(allCollaborators.size()));
655+
}
656+
648657
@Test
649658
public void getCheckRuns() throws Exception {
650659
final int expectedCount = 8;

‎src/test/resources/org/kohsuke/github/AppTest/wiremock/testMembership/mappings/repos_hub4j-test-org_jenkins_collaborators-4.json

Copy file name to clipboardExpand all lines: src/test/resources/org/kohsuke/github/AppTest/wiremock/testMembership/mappings/repos_hub4j-test-org_jenkins_collaborators-4.json
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,4 @@
4444
"uuid": "bce97482-6a11-44e5-a112-29230b142636",
4545
"persistent": true,
4646
"insertionIndex": 4
47-
}
47+
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.