From bbc42f8898816b64030e81d80ae58da6ae3c18e4 Mon Sep 17 00:00:00 2001 From: Kohsuke Kawaguchi Date: Fri, 6 Apr 2012 08:25:49 -0700 Subject: [PATCH 1/9] [maven-release-plugin] prepare for next development iteration --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 452fbaba7f..10b888842b 100644 --- a/pom.xml +++ b/pom.xml @@ -7,7 +7,7 @@ github-api - 1.19 + 1.20-SNAPSHOT GitHub API for Java http://github-api.kohsuke.org/ GitHub API for Java From 3a9b6665eeb2024ae3930ad6a59bb4aa26b9f40e Mon Sep 17 00:00:00 2001 From: Kohsuke Kawaguchi Date: Tue, 10 Apr 2012 12:43:59 -0700 Subject: [PATCH 2/9] exposed avatar_url --- src/main/java/org/kohsuke/github/GHPerson.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/main/java/org/kohsuke/github/GHPerson.java b/src/main/java/org/kohsuke/github/GHPerson.java index f58ff4e57a..eac321562b 100644 --- a/src/main/java/org/kohsuke/github/GHPerson.java +++ b/src/main/java/org/kohsuke/github/GHPerson.java @@ -58,11 +58,22 @@ public GHRepository getRepository(String name) throws IOException { /** * Gravatar ID of this user, like 0cb9832a01c22c083390f3c5dcb64105 + * + * @deprecated + * No longer available in the v3 API. */ public String getGravatarId() { return gravatar_id; } + /** + * Returns a string like 'https://secure.gravatar.com/avatar/0cb9832a01c22c083390f3c5dcb64105' + * that indicates the avatar image URL. + */ + public String getAvatarUrl() { + return avatar_url; + } + /** * Gets the login ID of this user, like 'kohsuke' */ From 3717d2ed320364778a194942274c9e7b58dd1195 Mon Sep 17 00:00:00 2001 From: Kohsuke Kawaguchi Date: Tue, 10 Apr 2012 12:57:25 -0700 Subject: [PATCH 3/9] emulate the value for V2 API --- src/main/java/org/kohsuke/github/GHPerson.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/kohsuke/github/GHPerson.java b/src/main/java/org/kohsuke/github/GHPerson.java index eac321562b..fa155ca454 100644 --- a/src/main/java/org/kohsuke/github/GHPerson.java +++ b/src/main/java/org/kohsuke/github/GHPerson.java @@ -71,7 +71,11 @@ public String getGravatarId() { * that indicates the avatar image URL. */ public String getAvatarUrl() { - return avatar_url; + if (avatar_url!=null) + return avatar_url; + if (gravatar_id!=null) + return "https://secure.gravatar.com/avatar/"+gravatar_id; + return null; } /** From 27701a75d97f07ecd382260362103b6a40c23966 Mon Sep 17 00:00:00 2001 From: Kohsuke Kawaguchi Date: Tue, 10 Apr 2012 13:03:55 -0700 Subject: [PATCH 4/9] Migrating to the V3 API --- src/main/java/org/kohsuke/github/GitHub.java | 18 +++-------- .../java/org/kohsuke/github/JsonUser.java | 31 ------------------- src/test/java/org/kohsuke/AppTest.java | 10 ++++++ 3 files changed, 15 insertions(+), 44 deletions(-) delete mode 100644 src/main/java/org/kohsuke/github/JsonUser.java diff --git a/src/main/java/org/kohsuke/github/GitHub.java b/src/main/java/org/kohsuke/github/GitHub.java index d95287f243..76b2684f15 100644 --- a/src/main/java/org/kohsuke/github/GitHub.java +++ b/src/main/java/org/kohsuke/github/GitHub.java @@ -245,7 +245,7 @@ private T _retrieve(String tailApiUrl, Class type, String method, boolean public GHMyself getMyself() throws IOException { requireCredential(); - GHMyself u = retrieveWithAuth("/user/show", JsonMyself.class).user; + GHMyself u = retrieveWithAuth3("/user", GHMyself.class); u.root = this; users.put(u.getLogin(), u); @@ -259,17 +259,9 @@ public GHMyself getMyself() throws IOException { public GHUser getUser(String login) throws IOException { GHUser u = users.get(login); if (u == null) { - - if (oauthAccessToken != null) { - u = retrieve("/user/show/" + login, JsonUser.class).user; - u.root = this; - users.put(u.getLogin(), u); - } else { - u = retrieve("/user/show/" + login, JsonUser.class).user; - u.root = this; - users.put(login, u); - } - + u = retrieve3("/users/" + login, GHUser.class); + u.root = this; + users.put(u.getLogin(), u); } return u; } @@ -352,7 +344,7 @@ public GHRepository createRepository(String name, String description, String hom */ public boolean isCredentialValid() throws IOException { try { - retrieveWithAuth("/user/show",JsonUser.class); + retrieveWithAuth3("/user",GHUser.class); return true; } catch (IOException e) { return false; diff --git a/src/main/java/org/kohsuke/github/JsonUser.java b/src/main/java/org/kohsuke/github/JsonUser.java deleted file mode 100644 index 1fae836dca..0000000000 --- a/src/main/java/org/kohsuke/github/JsonUser.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * The MIT License - * - * Copyright (c) 2010, Kohsuke Kawaguchi - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package org.kohsuke.github; - -/** - * @author Kohsuke Kawaguchi - */ -class JsonUser { - public GHUser user; -} diff --git a/src/test/java/org/kohsuke/AppTest.java b/src/test/java/org/kohsuke/AppTest.java index 06fcedb22a..c3d35d5350 100644 --- a/src/test/java/org/kohsuke/AppTest.java +++ b/src/test/java/org/kohsuke/AppTest.java @@ -7,10 +7,12 @@ import org.kohsuke.github.GHHook; import org.kohsuke.github.GHBranch; import org.kohsuke.github.GHIssueState; +import org.kohsuke.github.GHMyself; import org.kohsuke.github.GHOrganization; import org.kohsuke.github.GHOrganization.Permission; import org.kohsuke.github.GHRepository; import org.kohsuke.github.GHTeam; +import org.kohsuke.github.GHUser; import org.kohsuke.github.GitHub; import java.io.IOException; @@ -34,6 +36,14 @@ public void testFetchPullRequest() throws Exception { r.getPullRequest(1); r.getPullRequests(GHIssueState.OPEN); } + + public void testGetMyself() throws Exception { + GitHub hub = GitHub.connect(); + GHMyself me = hub.getMyself(); + System.out.println(me); + GHUser u = hub.getUser("kohsuke2"); + System.out.println(u); + } public void tryOrgFork() throws Exception { GitHub gh = GitHub.connect(); From 6f6ff56338cb08520f9b34c13cc89096f9c43599 Mon Sep 17 00:00:00 2001 From: Kohsuke Kawaguchi Date: Wed, 11 Apr 2012 09:26:26 -0700 Subject: [PATCH 5/9] exposed master_branch --- src/main/java/org/kohsuke/github/GHRepository.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/main/java/org/kohsuke/github/GHRepository.java b/src/main/java/org/kohsuke/github/GHRepository.java index 7684bfed14..329fd6f924 100644 --- a/src/main/java/org/kohsuke/github/GHRepository.java +++ b/src/main/java/org/kohsuke/github/GHRepository.java @@ -71,6 +71,8 @@ public class GHRepository { private int watchers,forks,open_issues; private String created_at, pushed_at; private Map milestones = new HashMap(); + + private String master_branch; public String getDescription() { return description; @@ -162,6 +164,15 @@ public Date getCreatedAt() { return GitHub.parseDate(created_at); } + /** + * Returns the primary branch you'll configure in the "Admin > Options" config page. + * + * @return + * This field is null until the user explicitly configures the master branch. + */ + public String getMasterBranch() { + return master_branch; + } /** * Gets the collaborators on this repository. From 7f4612f872fc143701832fe77dbbd7fc42010c58 Mon Sep 17 00:00:00 2001 From: Kohsuke Kawaguchi Date: Wed, 11 Apr 2012 09:27:47 -0700 Subject: [PATCH 6/9] exposed the size --- src/main/java/org/kohsuke/github/GHRepository.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/kohsuke/github/GHRepository.java b/src/main/java/org/kohsuke/github/GHRepository.java index 329fd6f924..86e805d53f 100644 --- a/src/main/java/org/kohsuke/github/GHRepository.java +++ b/src/main/java/org/kohsuke/github/GHRepository.java @@ -68,7 +68,7 @@ public class GHRepository { private String html_url; // this is the UI private GHUser owner; // not fully populated. beware. private boolean has_issues, has_wiki, fork, _private, has_downloads; - private int watchers,forks,open_issues; + private int watchers,forks,open_issues,size; private String created_at, pushed_at; private Map milestones = new HashMap(); @@ -174,6 +174,10 @@ public String getMasterBranch() { return master_branch; } + public int getSize() { + return size; + } + /** * Gets the collaborators on this repository. * This set always appear to include the owner. From 7e799d02e3b24600d0f76524dbbea82edd708d5a Mon Sep 17 00:00:00 2001 From: Kohsuke Kawaguchi Date: Wed, 11 Apr 2012 09:29:28 -0700 Subject: [PATCH 7/9] Added test-ish --- src/test/java/org/kohsuke/AppTest.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/test/java/org/kohsuke/AppTest.java b/src/test/java/org/kohsuke/AppTest.java index c3d35d5350..8260a1dce0 100644 --- a/src/test/java/org/kohsuke/AppTest.java +++ b/src/test/java/org/kohsuke/AppTest.java @@ -33,11 +33,12 @@ public void testCredentialValid() throws IOException { public void testFetchPullRequest() throws Exception { GitHub gh = GitHub.connect(); GHRepository r = gh.getOrganization("jenkinsci").getRepository("jenkins"); + assertEquals("master",r.getMasterBranch()); r.getPullRequest(1); r.getPullRequests(GHIssueState.OPEN); } - public void testGetMyself() throws Exception { + public void tryGetMyself() throws Exception { GitHub hub = GitHub.connect(); GHMyself me = hub.getMyself(); System.out.println(me); From 095604d4caf0ceaf6b6991d767e96375226bfa01 Mon Sep 17 00:00:00 2001 From: Kohsuke Kawaguchi Date: Wed, 11 Apr 2012 09:32:22 -0700 Subject: [PATCH 8/9] updated the parent version --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 10b888842b..7ac0edb6e5 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ org.kohsuke pom - 1 + 3 github-api From 7cda083b31fdb95b7464bc331669cf9280ab3cbf Mon Sep 17 00:00:00 2001 From: Kohsuke Kawaguchi Date: Wed, 11 Apr 2012 09:32:46 -0700 Subject: [PATCH 9/9] [maven-release-plugin] prepare release github-api-1.20 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 7ac0edb6e5..1ada8628b5 100644 --- a/pom.xml +++ b/pom.xml @@ -7,7 +7,7 @@ github-api - 1.20-SNAPSHOT + 1.20 GitHub API for Java http://github-api.kohsuke.org/ GitHub API for Java