Skip to content

File tree

443 files changed

+24960
-19554
lines changed

Some content is hidden

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

443 files changed

+24960
-19554
lines changed

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/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/AppTest/wiremock/testMyTeamsShouldIncludeMyself/__files/organizations_107424_teams-11.json

Lines changed: 0 additions & 327 deletions
This file was deleted.

0 commit comments

Comments
 (0)