This commit is contained in:
Kohsuke Kawaguchi
2010-12-12 21:17:08 -08:00
parent a282cd3f74
commit bbf045dbf1
2 changed files with 10 additions and 6 deletions

View File

@@ -44,6 +44,7 @@ public abstract class GHPerson {
* Fetches the repository of the given name from GitHub, and return it.
*/
protected GHRepository refreshRepository(String name) throws IOException {
if (repositories==null) getRepositories(); // fetch the base first
GHRepository r = root.retrieve("/repos/show/" + login + '/' + name, JsonRepository.class).wrap(root);
repositories.put(name,r);
return r;

View File

@@ -1,7 +1,6 @@
package org.kohsuke.github;
import java.io.IOException;
import java.net.URL;
import java.util.Set;
/**
@@ -31,28 +30,32 @@ public class GHTeam {
* Retrieves the current members.
*/
public Set<GHUser> getMembers() throws IOException {
return org.root.retrieveWithAuth("/members",JsonUsersWithDetails.class).toSet(org.root);
return org.root.retrieveWithAuth(api("/members"),JsonUsersWithDetails.class).toSet(org.root);
}
/**
* Adds a member to the team.
*/
public void add(GHUser u) throws IOException {
org.root.retrieveWithAuth("/members?name="+u.getLogin(),null, "POST");
org.root.retrieveWithAuth(api("/members?name="+u.getLogin()),null, "POST");
}
/**
* Removes a member to the team.
*/
public void remove(GHUser u) throws IOException {
org.root.retrieveWithAuth("/members?name="+u.getLogin(),null, "DELETE");
org.root.retrieveWithAuth(api("/members?name="+u.getLogin()),null, "DELETE");
}
public void add(GHRepository r) throws IOException {
org.root.retrieveWithAuth("/repositories?name="+r.getOwnerName()+'/'+r.getName(),null, "POST");
org.root.retrieveWithAuth(api("/repositories?name="+r.getOwnerName()+'/'+r.getName()),null, "POST");
}
public void remove(GHRepository r) throws IOException {
org.root.retrieveWithAuth("/repositories?name="+r.getOwnerName()+'/'+r.getName(),null, "DELETE");
org.root.retrieveWithAuth(api("/repositories?name="+r.getOwnerName()+'/'+r.getName()),null, "DELETE");
}
private String api(String tail) {
return "/teams/"+id+tail;
}
}