From bbc78ffec6e1dc586d278576fcb033725b6b951f Mon Sep 17 00:00:00 2001 From: Kohsuke Kawaguchi Date: Sat, 7 Sep 2013 13:32:24 +0100 Subject: [PATCH 01/13] [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 ff3f7d820b..7b2c82df0b 100644 --- a/pom.xml +++ b/pom.xml @@ -7,7 +7,7 @@ github-api - 1.44 + 1.45-SNAPSHOT GitHub API for Java http://github-api.kohsuke.org/ GitHub API for Java From f52b4a2e113657ab12b0c4d35550451a7dea390d Mon Sep 17 00:00:00 2001 From: Luca Milanesio Date: Mon, 16 Sep 2013 00:40:32 +0100 Subject: [PATCH 02/13] Allows to define page size for repository lists. Extension of the listRepositories() with the desired pageSize. This allows to reduce the number of calls to GitHub API for fetching the entire set of repositories browsing all the pages. Additionally allows to match the UX paging with the underlying GitHub API paging, increasing performance and reducing hourly API allowance. --- src/main/java/org/kohsuke/github/GHPerson.java | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/kohsuke/github/GHPerson.java b/src/main/java/org/kohsuke/github/GHPerson.java index 721eeb2257..18a7313e35 100644 --- a/src/main/java/org/kohsuke/github/GHPerson.java +++ b/src/main/java/org/kohsuke/github/GHPerson.java @@ -55,14 +55,25 @@ public synchronized Map getRepositories() throws IOExceptio } /** - * Lists up all the repositories. + * Lists up all the repositories using a 30 items page size. * * Unlike {@link #getRepositories()}, this does not wait until all the repositories are returned. */ public PagedIterable listRepositories() { + return listRepositories(30); + } + + /** + * Lists up all the repositories using the specified page size. + * + * @param pageSize size for each page of items returned by GitHub. Maximum page size is 100. + * + * Unlike {@link #getRepositories()}, this does not wait until all the repositories are returned. + */ + public PagedIterable listRepositories(final int pageSize) { return new PagedIterable() { public PagedIterator iterator() { - return new PagedIterator(root.retrieve().asIterator("/users/" + login + "/repos", GHRepository[].class)) { + return new PagedIterator(root.retrieve().asIterator("/users/" + login + "/repos?per_page=" + pageSize, GHRepository[].class)) { @Override protected void wrapUp(GHRepository[] page) { for (GHRepository c : page) From 2fb3f3193074cc9b2dc4095a4578f0a3a2e36c5d Mon Sep 17 00:00:00 2001 From: Luca Milanesio Date: Fri, 27 Sep 2013 09:12:54 +0100 Subject: [PATCH 03/13] GHRepository owner is NOT a GHUser but more generically a GHPerson. When GitHub repositories are associated to organisations, the owner is NOT the user but the org itself. --- src/main/java/org/kohsuke/github/GHPerson.java | 2 +- src/main/java/org/kohsuke/github/GHRepository.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/kohsuke/github/GHPerson.java b/src/main/java/org/kohsuke/github/GHPerson.java index 18a7313e35..687093d1df 100644 --- a/src/main/java/org/kohsuke/github/GHPerson.java +++ b/src/main/java/org/kohsuke/github/GHPerson.java @@ -14,7 +14,7 @@ * * @author Kohsuke Kawaguchi */ -public abstract class GHPerson { +public class GHPerson { /*package almost final*/ GitHub root; // core data fields that exist even for "small" user data (such as the user info in pull request) diff --git a/src/main/java/org/kohsuke/github/GHRepository.java b/src/main/java/org/kohsuke/github/GHRepository.java index 5302413c3a..0cce0837d6 100644 --- a/src/main/java/org/kohsuke/github/GHRepository.java +++ b/src/main/java/org/kohsuke/github/GHRepository.java @@ -57,7 +57,7 @@ public class GHRepository { private String description, homepage, name; private String url; // this is the API url private String html_url; // this is the UI - private GHUser owner; // not fully populated. beware. + private GHPerson owner; // not fully populated. beware. private boolean has_issues, has_wiki, fork, _private, has_downloads; private int watchers,forks,open_issues,size; private String created_at, pushed_at; From 096c96550bb4921d7932b3dcad5f20b3de1a626a Mon Sep 17 00:00:00 2001 From: Luca Milanesio Date: Fri, 27 Sep 2013 09:18:22 +0100 Subject: [PATCH 04/13] Allows fetching pull requests by knowing repo-name and owner. --- 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 0cce0837d6..31f16785f7 100644 --- a/src/main/java/org/kohsuke/github/GHRepository.java +++ b/src/main/java/org/kohsuke/github/GHRepository.java @@ -378,6 +378,17 @@ protected void wrapUp(GHPullRequest[] page) { }; } + /** + * Retrieves all the pull requests of a particular state by knowing organisation and repository + */ + public static PagedIterable listPullRequests(final GitHub root, final GHPerson owner, final String repositoryName, final GHIssueState state) { + GHRepository repo = new GHRepository(); + repo.root = root; + repo.name = repositoryName; + repo.owner = owner; + return repo.listPullRequests(state); + } + /** * Retrieves the currently configured hooks. */ From a2df4217fd5a770514805b932afe63bd5b836c93 Mon Sep 17 00:00:00 2001 From: Ricardo Pescuma Domenecci Date: Sat, 28 Sep 2013 12:43:01 -0300 Subject: [PATCH 05/13] Updated issue label with ifts fields --- src/main/java/org/kohsuke/github/GHIssue.java | 22 +++++++++++++++++-- .../org/kohsuke/github/GHPullRequest.java | 2 +- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/kohsuke/github/GHIssue.java b/src/main/java/org/kohsuke/github/GHIssue.java index 636ebb7c51..dfd73dc785 100644 --- a/src/main/java/org/kohsuke/github/GHIssue.java +++ b/src/main/java/org/kohsuke/github/GHIssue.java @@ -49,7 +49,7 @@ public class GHIssue { protected String closed_at; protected int comments; protected String body; - protected List labels; + protected List