Skip to content

Commit a075a9e

Browse files
authored
Merge branch 'main' into add_gitcommit_class
2 parents 4fbe46e + a35c1f6 commit a075a9e

462 files changed

Lines changed: 25234 additions & 20127 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.

pom.xml

Lines changed: 32 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<modelVersion>4.0.0</modelVersion>
33
<groupId>org.kohsuke</groupId>
44
<artifactId>github-api</artifactId>
5-
<version>1.302-SNAPSHOT</version>
5+
<version>1.304-SNAPSHOT</version>
66
<name>GitHub API for Java</name>
77
<url>https://github-api.kohsuke.org/</url>
88
<description>GitHub API for Java</description>
@@ -213,7 +213,7 @@
213213
<plugin>
214214
<groupId>org.apache.maven.plugins</groupId>
215215
<artifactId>maven-javadoc-plugin</artifactId>
216-
<version>3.3.1</version>
216+
<version>3.3.2</version>
217217
<configuration>
218218
<source>8</source>
219219
<failOnWarnings>true</failOnWarnings>
@@ -223,7 +223,7 @@
223223
<plugin>
224224
<groupId>org.sonatype.plugins</groupId>
225225
<artifactId>nexus-staging-maven-plugin</artifactId>
226-
<version>1.6.8</version>
226+
<version>1.6.12</version>
227227
<extensions>true</extensions>
228228
<configuration>
229229
<serverId>sonatype-nexus-staging</serverId>
@@ -234,7 +234,7 @@
234234
<plugin>
235235
<groupId>org.codehaus.mojo</groupId>
236236
<artifactId>animal-sniffer-maven-plugin</artifactId>
237-
<version>1.20</version>
237+
<version>1.21</version>
238238
<configuration>
239239
<signature>
240240
<groupId>org.codehaus.mojo.signature</groupId>
@@ -258,7 +258,7 @@
258258
<plugin>
259259
<groupId>org.apache.maven.plugins</groupId>
260260
<artifactId>maven-site-plugin</artifactId>
261-
<version>3.10.0</version>
261+
<version>3.11.0</version>
262262
</plugin>
263263
<plugin>
264264
<groupId>org.apache.maven.plugins</groupId>
@@ -278,7 +278,7 @@
278278
<plugin>
279279
<groupId>org.apache.maven.plugins</groupId>
280280
<artifactId>maven-project-info-reports-plugin</artifactId>
281-
<version>3.1.2</version>
281+
<version>3.2.2</version>
282282
<dependencies>
283283
<dependency>
284284
<groupId>org.apache.bcel</groupId>
@@ -289,7 +289,7 @@
289289
</plugin>
290290
<plugin>
291291
<artifactId>maven-compiler-plugin</artifactId>
292-
<version>3.9.0</version>
292+
<version>3.10.0</version>
293293
<configuration>
294294
<source>1.8</source>
295295
<target>1.8</target>
@@ -333,7 +333,7 @@
333333
<plugin>
334334
<groupId>com.diffplug.spotless</groupId>
335335
<artifactId>spotless-maven-plugin</artifactId>
336-
<version>2.20.0</version>
336+
<version>2.21.0</version>
337337
<executions>
338338
<execution>
339339
<id>spotless-check</id>
@@ -393,6 +393,26 @@
393393
</dependency>
394394
</dependencies>
395395
</plugin>
396+
<plugin>
397+
<groupId>com.github.siom79.japicmp</groupId>
398+
<artifactId>japicmp-maven-plugin</artifactId>
399+
<version>0.15.7</version>
400+
<configuration>
401+
<parameter>
402+
<breakBuildOnBinaryIncompatibleModifications>true</breakBuildOnBinaryIncompatibleModifications>
403+
<onlyModified>true</onlyModified>
404+
<includeSynthetic>true</includeSynthetic>
405+
</parameter>
406+
</configuration>
407+
<executions>
408+
<execution>
409+
<phase>verify</phase>
410+
<goals>
411+
<goal>cmp</goal>
412+
</goals>
413+
</execution>
414+
</executions>
415+
</plugin>
396416
</plugins>
397417
</build>
398418

@@ -405,7 +425,7 @@
405425
<dependency>
406426
<groupId>com.tngtech.archunit</groupId>
407427
<artifactId>archunit</artifactId>
408-
<version>0.22.0</version>
428+
<version>0.23.1</version>
409429
<scope>test</scope>
410430
</dependency>
411431
<dependency>
@@ -559,13 +579,13 @@
559579
<dependency>
560580
<groupId>com.google.code.gson</groupId>
561581
<artifactId>gson</artifactId>
562-
<version>2.8.9</version>
582+
<version>2.9.0</version>
563583
<scope>test</scope>
564584
</dependency>
565585
<dependency>
566586
<groupId>org.slf4j</groupId>
567587
<artifactId>slf4j-simple</artifactId>
568-
<version>1.7.35</version>
588+
<version>1.7.36</version>
569589
<scope>test</scope>
570590
</dependency>
571591
</dependencies>
@@ -768,7 +788,7 @@
768788
</plugin>
769789
<plugin>
770790
<artifactId>maven-compiler-plugin</artifactId>
771-
<version>3.9.0</version>
791+
<version>3.10.0</version>
772792
<executions>
773793
<execution>
774794
<id>compile-java-11</id>

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

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package org.kohsuke.github;
22

33
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
4+
import org.apache.commons.lang3.StringUtils;
45

56
import java.io.IOException;
67
import java.net.URL;
@@ -211,7 +212,7 @@ public Set<GHUser> getMembers() throws IOException {
211212
*/
212213
public boolean hasMember(GHUser user) {
213214
try {
214-
root().createRequest().withUrlPath("/teams/" + getId() + "/members/" + user.getLogin()).send();
215+
root().createRequest().withUrlPath(api("/memberships/" + user.getLogin())).send();
215216
return true;
216217
} catch (IOException ignore) {
217218
return false;
@@ -345,7 +346,13 @@ public void delete() throws IOException {
345346
}
346347

347348
private String api(String tail) {
348-
return "/teams/" + getId() + tail;
349+
if (organization == null) {
350+
// Teams returned from pull requests to do not have an organization. Attempt to use url.
351+
final URL url = Objects.requireNonNull(getUrl(), "Missing instance URL!");
352+
return StringUtils.prependIfMissing(url.toString().replace(root().getApiUrl(), ""), "/") + tail;
353+
}
354+
355+
return "/organizations/" + organization.getId() + "/team/" + getId() + tail;
349356
}
350357

351358
/**

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

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -874,7 +874,9 @@ public Map<String, Set<GHTeam>> getMyTeams() throws IOException {
874874
}
875875

876876
/**
877-
* Gets a sigle team by ID.
877+
* Gets a single team by ID.
878+
* <p>
879+
* This method is no longer supported and throws an UnsupportedOperationException.
878880
*
879881
* @param id
880882
* the id
@@ -883,11 +885,14 @@ public Map<String, Set<GHTeam>> getMyTeams() throws IOException {
883885
* the io exception
884886
*
885887
* @deprecated Use {@link GHOrganization#getTeam(long)}
886-
* @see <a href= "https://developer.github.com/v3/teams/#get-team-legacy">deprecation notice</a>
888+
* @see <a href="https://developer.github.com/v3/teams/#get-team-legacy">deprecation notice</a>
889+
* @see <a href="https://github.blog/changelog/2022-02-22-sunset-notice-deprecated-teams-api-endpoints/">sunset
890+
* notice</a>
887891
*/
888892
@Deprecated
889893
public GHTeam getTeam(int id) throws IOException {
890-
return createRequest().withUrlPath("/teams/" + id).fetch(GHTeam.class).wrapUp(this);
894+
throw new UnsupportedOperationException(
895+
"This method is not supported anymore. Please use GHOrganization#getTeam(long).");
891896
}
892897

893898
/**

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

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import java.util.stream.Collectors;
2222

2323
import static org.hamcrest.Matchers.*;
24+
import static org.junit.Assert.assertThrows;
2425

2526
/**
2627
* Unit test for simple App.
@@ -444,15 +445,12 @@ private boolean shouldBelongToTeam(String organizationName, String teamName) thr
444445
}
445446

446447
@Test
447-
public void testShouldFetchTeam() throws Exception {
448+
@SuppressWarnings("deprecation")
449+
public void testFetchingTeamFromGitHubInstanceThrowsException() throws Exception {
448450
GHOrganization organization = gitHub.getOrganization(GITHUB_API_TEST_ORG);
449451
GHTeam teamByName = organization.getTeams().get("Core Developers");
450452

451-
GHTeam teamById = gitHub.getTeam((int) teamByName.getId());
452-
assertThat(teamById, notNullValue());
453-
454-
assertThat(teamById.getId(), equalTo(teamByName.getId()));
455-
assertThat(teamById.getDescription(), equalTo(teamByName.getDescription()));
453+
assertThrows(UnsupportedOperationException.class, () -> gitHub.getTeam((int) teamByName.getId()));
456454
}
457455

458456
@Test

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,9 @@ public void listMembersNoMatch() throws IOException {
9191

9292
@Test
9393
public void testSetPrivacy() throws IOException {
94-
String teamSlug = "dummy-team";
94+
// we need to use a team that doesn't have child teams
95+
// as secret privacy is not supported for parent teams
96+
String teamSlug = "simple-team";
9597
Privacy privacy = Privacy.CLOSED;
9698

9799
// Set the privacy.

src/test/resources/org/kohsuke/github/GHTeamTest/wiremock/listMembers/__files/orgs_hub4j-test-org-2.json renamed to src/test/resources/org/kohsuke/github/AppTest/wiremock/testFetchingTeamFromGitHubInstanceThrowsException/__files/orgs_hub4j-test-org-1.json

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,31 +20,36 @@
2020
"is_verified": false,
2121
"has_organization_projects": true,
2222
"has_repository_projects": true,
23-
"public_repos": 19,
23+
"public_repos": 49,
2424
"public_gists": 0,
2525
"followers": 0,
2626
"following": 0,
2727
"html_url": "https://github.com/hub4j-test-org",
2828
"created_at": "2014-05-10T19:39:11Z",
2929
"updated_at": "2020-06-04T05:56:10Z",
3030
"type": "Organization",
31-
"total_private_repos": 2,
32-
"owned_private_repos": 2,
31+
"total_private_repos": 3,
32+
"owned_private_repos": 3,
3333
"private_gists": 0,
3434
"disk_usage": 11979,
3535
"collaborators": 0,
3636
"billing_email": "kk@kohsuke.org",
3737
"default_repository_permission": "none",
3838
"members_can_create_repositories": false,
3939
"two_factor_requirement_enabled": false,
40+
"members_allowed_repository_creation_type": "none",
41+
"members_can_create_public_repositories": false,
42+
"members_can_create_private_repositories": false,
43+
"members_can_create_internal_repositories": false,
4044
"members_can_create_pages": true,
45+
"members_can_fork_private_repositories": false,
4146
"members_can_create_public_pages": true,
4247
"members_can_create_private_pages": true,
4348
"plan": {
4449
"name": "free",
4550
"space": 976562499,
4651
"private_repos": 10000,
47-
"filled_seats": 26,
52+
"filled_seats": 35,
4853
"seats": 3
4954
}
5055
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
[
2+
{
3+
"name": "child-team-for-dummy",
4+
"id": 3903497,
5+
"node_id": "MDQ6VGVhbTM5MDM0OTc=",
6+
"slug": "child-team-for-dummy",
7+
"description": "to test the fetching of child teams",
8+
"privacy": "closed",
9+
"url": "https://api.github.com/organizations/7544739/team/3903497",
10+
"html_url": "https://github.com/orgs/hub4j-test-org/teams/child-team-for-dummy",
11+
"members_url": "https://api.github.com/organizations/7544739/team/3903497/members{/member}",
12+
"repositories_url": "https://api.github.com/organizations/7544739/team/3903497/repos",
13+
"permission": "pull",
14+
"parent": {
15+
"name": "dummy-team",
16+
"id": 3451996,
17+
"node_id": "MDQ6VGVhbTM0NTE5OTY=",
18+
"slug": "dummy-team",
19+
"description": "Updated by API TestModified",
20+
"privacy": "closed",
21+
"url": "https://api.github.com/organizations/7544739/team/3451996",
22+
"html_url": "https://github.com/orgs/hub4j-test-org/teams/dummy-team",
23+
"members_url": "https://api.github.com/organizations/7544739/team/3451996/members{/member}",
24+
"repositories_url": "https://api.github.com/organizations/7544739/team/3451996/repos",
25+
"permission": "pull"
26+
}
27+
},
28+
{
29+
"name": "Contributors",
30+
"id": 4882699,
31+
"node_id": "MDQ6VGVhbTQ4ODI2OTk=",
32+
"slug": "contributors",
33+
"description": "",
34+
"privacy": "closed",
35+
"url": "https://api.github.com/organizations/7544739/team/4882699",
36+
"html_url": "https://github.com/orgs/hub4j-test-org/teams/contributors",
37+
"members_url": "https://api.github.com/organizations/7544739/team/4882699/members{/member}",
38+
"repositories_url": "https://api.github.com/organizations/7544739/team/4882699/repos",
39+
"permission": "pull",
40+
"parent": null
41+
},
42+
{
43+
"name": "Core Developers",
44+
"id": 820406,
45+
"node_id": "MDQ6VGVhbTgyMDQwNg==",
46+
"slug": "core-developers",
47+
"description": "A random team",
48+
"privacy": "secret",
49+
"url": "https://api.github.com/organizations/7544739/team/820406",
50+
"html_url": "https://github.com/orgs/hub4j-test-org/teams/core-developers",
51+
"members_url": "https://api.github.com/organizations/7544739/team/820406/members{/member}",
52+
"repositories_url": "https://api.github.com/organizations/7544739/team/820406/repos",
53+
"permission": "pull",
54+
"parent": null
55+
},
56+
{
57+
"name": "dummy-team",
58+
"id": 3451996,
59+
"node_id": "MDQ6VGVhbTM0NTE5OTY=",
60+
"slug": "dummy-team",
61+
"description": "Updated by API TestModified",
62+
"privacy": "closed",
63+
"url": "https://api.github.com/organizations/7544739/team/3451996",
64+
"html_url": "https://github.com/orgs/hub4j-test-org/teams/dummy-team",
65+
"members_url": "https://api.github.com/organizations/7544739/team/3451996/members{/member}",
66+
"repositories_url": "https://api.github.com/organizations/7544739/team/3451996/repos",
67+
"permission": "pull",
68+
"parent": null
69+
},
70+
{
71+
"name": "Owners-team",
72+
"id": 820404,
73+
"node_id": "MDQ6VGVhbTgyMDQwNA==",
74+
"slug": "owners-team",
75+
"description": null,
76+
"privacy": "secret",
77+
"url": "https://api.github.com/organizations/7544739/team/820404",
78+
"html_url": "https://github.com/orgs/hub4j-test-org/teams/owners-team",
79+
"members_url": "https://api.github.com/organizations/7544739/team/820404/members{/member}",
80+
"repositories_url": "https://api.github.com/organizations/7544739/team/820404/repos",
81+
"permission": "pull",
82+
"parent": null
83+
},
84+
{
85+
"name": "simple-team",
86+
"id": 3947450,
87+
"node_id": "MDQ6VGVhbTM5NDc0NTA=",
88+
"slug": "simple-team",
89+
"description": "A simple team with no children",
90+
"privacy": "secret",
91+
"url": "https://api.github.com/organizations/7544739/team/3947450",
92+
"html_url": "https://github.com/orgs/hub4j-test-org/teams/simple-team",
93+
"members_url": "https://api.github.com/organizations/7544739/team/3947450/members{/member}",
94+
"repositories_url": "https://api.github.com/organizations/7544739/team/3947450/repos",
95+
"permission": "pull",
96+
"parent": null
97+
},
98+
{
99+
"name": "tricky-team",
100+
"id": 3454508,
101+
"node_id": "MDQ6VGVhbTM0NTQ1MDg=",
102+
"slug": "tricky-team",
103+
"description": "",
104+
"privacy": "secret",
105+
"url": "https://api.github.com/organizations/7544739/team/3454508",
106+
"html_url": "https://github.com/orgs/hub4j-test-org/teams/tricky-team",
107+
"members_url": "https://api.github.com/organizations/7544739/team/3454508/members{/member}",
108+
"repositories_url": "https://api.github.com/organizations/7544739/team/3454508/repos",
109+
"permission": "pull",
110+
"parent": null
111+
}
112+
]

0 commit comments

Comments
 (0)