Compare commits

..

4 Commits

Author SHA1 Message Date
Kohsuke Kawaguchi
69a87e2ab7 [maven-release-plugin] prepare release github-api-1.28 2012-06-13 08:27:53 -07:00
Kohsuke Kawaguchi
8ec2686e72 getName() is null with shallow retrieval 2012-06-13 08:12:18 -07:00
Kohsuke Kawaguchi
d034ca4d1f removed unused V3 API 2012-06-13 08:10:01 -07:00
Kohsuke Kawaguchi
61cf71fd67 [maven-release-plugin] prepare for next development iteration 2012-06-12 14:26:30 -07:00
4 changed files with 19 additions and 9 deletions

View File

@@ -7,7 +7,7 @@
</parent>
<artifactId>github-api</artifactId>
<version>1.27</version>
<version>1.28</version>
<name>GitHub API for Java</name>
<url>http://github-api.kohsuke.org/</url>
<description>GitHub API for Java</description>

View File

@@ -22,9 +22,6 @@ public abstract class GHPerson {
protected int id;
protected String gravatar_id; // appears in V3 as well but presumably subsumed by avatar_url?
// V2
protected int public_gist_count,public_repo_count,followers_count,following_count;
// V3
protected String avatar_url,html_url;
protected int followers,following,public_repos,public_gists;
@@ -163,15 +160,15 @@ public abstract class GHPerson {
}
public int getPublicGistCount() {
return Math.max(public_gist_count,public_gists);
return public_gists;
}
public int getPublicRepoCount() {
return Math.max(public_repo_count,public_repos);
return public_repos;
}
public int getFollowingCount() {
return Math.max(following_count,following);
return following;
}
/**
@@ -182,7 +179,7 @@ public abstract class GHPerson {
}
public int getFollowersCount() {
return Math.max(followers_count,followers);
return followers;
}
}

View File

@@ -415,11 +415,18 @@ public class GitHub {
return getUser(tokens[0]).getRepository(tokens[1]);
}
/**
* This method returns a shallowly populated organizations.
*
* To retrieve full organization details, you need to call {@link #getOrganization(String)}
* TODO: make this automatic.
*/
public Map<String, GHOrganization> getMyOrganizations() throws IOException {
GHOrganization[] orgs = retrieveWithAuth("/user/orgs", GHOrganization[].class);
Map<String, GHOrganization> r = new HashMap<String, GHOrganization>();
for (GHOrganization o : orgs) {
r.put(o.name,o.wrapUp(this));
// don't put 'o' into orgs because they are shallow
r.put(o.getLogin(),o.wrapUp(this));
}
return r;
}

View File

@@ -40,6 +40,12 @@ public class AppTest extends TestCase {
System.out.println(GitHub.connect().getRateLimit());
}
public void testMyOrganizations() throws IOException {
Map<String, GHOrganization> org = GitHub.connect().getMyOrganizations();
assertFalse(org.keySet().contains(null));
System.out.println(org);
}
public void testFetchPullRequest() throws Exception {
GitHub gh = GitHub.connect();
GHRepository r = gh.getOrganization("jenkinsci").getRepository("jenkins");