Skip to content

Commit

Permalink
Merge pull request #281 from apemberton/master
Browse files Browse the repository at this point in the history
Add Slug to GHTeam per v3 API: https://developer.github.com/v3/orgs/t…
  • Loading branch information
kohsuke committed Jun 3, 2016
2 parents 3d301ec + d530b34 commit 204e639
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
11 changes: 11 additions & 0 deletions src/main/java/org/kohsuke/github/GHOrganization.java
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,17 @@ public GHTeam getTeamByName(String name) throws IOException {
return null;
}

/**
* Finds a team that has the given slug in its {@link GHTeam#getSlug()}
*/
public GHTeam getTeamBySlug(String slug) throws IOException {
for (GHTeam t : listTeams()) {
if(t.getSlug().equals(slug))
return t;
}
return null;
}

/**
* Checks if this organization has the specified user as a member.
*/
Expand Down
6 changes: 5 additions & 1 deletion src/main/java/org/kohsuke/github/GHTeam.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* @author Kohsuke Kawaguchi
*/
public class GHTeam {
private String name,permission;
private String name,permission,slug;
private int id;
private GHOrganization organization; // populated by GET /user/teams where Teams+Orgs are returned together

Expand Down Expand Up @@ -43,6 +43,10 @@ public String getPermission() {
return permission;
}

public String getSlug() {
return slug;
}

public int getId() {
return id;
}
Expand Down
7 changes: 7 additions & 0 deletions src/test/java/org/kohsuke/github/AppTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,13 @@ public void testOrgTeamByName() throws Exception {
assertNotNull(e);
}

@Test
public void testOrgTeamBySlug() throws Exception {
kohsuke();
GHTeam e = gitHub.getOrganization("github-api-test-org").getTeamBySlug("core-developers");
assertNotNull(e);
}

@Test
public void testCommit() throws Exception {
GHCommit commit = gitHub.getUser("jenkinsci").getRepository("jenkins").getCommit("08c1c9970af4d609ae754fbe803e06186e3206f7");
Expand Down

0 comments on commit 204e639

Please sign in to comment.