Compare commits

...

15 Commits

Author SHA1 Message Date
Kohsuke Kawaguchi
4956278f17 [maven-release-plugin] prepare release github-api-1.43 2013-07-06 22:26:39 -07:00
Kohsuke Kawaguchi
5858a86624 using the latest 2013-07-06 22:24:21 -07:00
Kohsuke Kawaguchi
c87d178a6a added a method that matches the convention elsewhere. 2013-07-06 17:49:56 -07:00
Kohsuke Kawaguchi
6fc872b1fd this is no longer efficient 2013-07-06 17:49:46 -07:00
Kohsuke Kawaguchi
589c5783a0 "myself" only makes sense when there's a credential 2013-05-24 12:01:56 -07:00
Kohsuke Kawaguchi
40165628d6 [maven-release-plugin] prepare for next development iteration 2013-05-07 11:09:20 -07:00
Kohsuke Kawaguchi
435be77249 [maven-release-plugin] prepare release github-api-1.42 2013-05-07 11:09:13 -07:00
Kohsuke Kawaguchi
b932ba856d fixed NPE 2013-05-07 11:07:12 -07:00
Kohsuke Kawaguchi
094514f617 Merge pull request #36 from spiffxp/require-credentials-fix
Allow oauthToken to be used without login
2013-05-06 14:34:06 -07:00
Kohsuke Kawaguchi
fab96879d0 Merge pull request #37 from spiffxp/pr-comments-fix
Force issues-based API route for PR comments
2013-05-06 14:33:29 -07:00
Kohsuke Kawaguchi
367a5f0c57 Merge pull request #38 from janinko/fixPullRequestPayload
add repository to Pull Request payload and wrap the PR with the repository
2013-05-06 14:32:11 -07:00
Honza Brázdil
0d2ecfbc67 add repository to Pull Request payload and wrap the PR with the repository 2013-05-02 18:11:40 +02:00
Aaron Crickenberger
5410ba3b1d Force issues-based API route for PR comments
pulls/:number/comments is used for review_comments
2013-05-01 13:59:45 -07:00
Aaron Crickenberger
716bfd4611 requireCredential should allow for oauthToken with no login 2013-04-30 15:41:08 -07:00
Kohsuke Kawaguchi
3830a58493 [maven-release-plugin] prepare for next development iteration 2013-04-23 10:30:54 -07:00
6 changed files with 48 additions and 9 deletions

View File

@@ -3,11 +3,11 @@
<parent>
<groupId>org.kohsuke</groupId>
<artifactId>pom</artifactId>
<version>4</version>
<version>6</version>
</parent>
<artifactId>github-api</artifactId>
<version>1.41</version>
<version>1.43</version>
<name>GitHub API for Java</name>
<url>http://github-api.kohsuke.org/</url>
<description>GitHub API for Java</description>

View File

@@ -27,6 +27,7 @@ public abstract class GHEventPayload {
private String action;
private int number;
private GHPullRequest pull_request;
private GHRepository repository;
public String getAction() {
return action;
@@ -41,10 +42,19 @@ public abstract class GHEventPayload {
return pull_request;
}
public GHRepository getRepository() {
return repository;
}
@Override
void wrapUp(GitHub root) {
super.wrapUp(root);
pull_request.wrapUp(root);
if (repository!=null) {
repository.wrap(root);
pull_request.wrap(repository);
} else {
pull_request.wrapUp(root);
}
}
}

View File

@@ -138,7 +138,7 @@ public class GHIssue {
* Updates the issue by adding a comment.
*/
public void comment(String message) throws IOException {
new Requester(root).with("body",message).to(getApiRoute() + "/comments");
new Requester(root).with("body",message).to(getIssuesApiRoute() + "/comments");
}
private void edit(String key, Object value) throws IOException {
@@ -190,7 +190,7 @@ public class GHIssue {
public PagedIterable<GHIssueComment> listComments() throws IOException {
return new PagedIterable<GHIssueComment>() {
public PagedIterator<GHIssueComment> iterator() {
return new PagedIterator<GHIssueComment>(root.retrieve().asIterator(getApiRoute() + "/comments", GHIssueComment[].class)) {
return new PagedIterator<GHIssueComment>(root.retrieve().asIterator(getIssuesApiRoute() + "/comments", GHIssueComment[].class)) {
protected void wrapUp(GHIssueComment[] page) {
for (GHIssueComment c : page)
c.wrapUp(GHIssue.this);
@@ -201,6 +201,10 @@ public class GHIssue {
}
protected String getApiRoute() {
return getIssuesApiRoute();
}
private String getIssuesApiRoute() {
return "/repos/"+owner.getOwnerName()+"/"+owner.getName()+"/issues/"+number;
}
@@ -250,4 +254,4 @@ public class GHIssue {
return GitHub.parseURL(html_url);
}
}
}
}

View File

@@ -130,10 +130,13 @@ public class GHOrganization extends GHPerson {
/**
* List up repositories that has some open pull requests.
*
* This used to be an efficient method that didn't involve traversing every repository, but now
* it doesn't do any optimization.
*/
public List<GHRepository> getRepositoriesWithOpenPullRequests() throws IOException {
List<GHRepository> r = new ArrayList<GHRepository>();
for (GHRepository repository : root.retrieve().to("/orgs/" + login + "/repos", GHRepository[].class)) {
for (GHRepository repository : listRepositories()) {
repository.wrap(root);
List<GHPullRequest> pullRequests = repository.getPullRequests(GHIssueState.OPEN);
if (pullRequests.size() > 0) {

View File

@@ -54,6 +54,25 @@ public abstract class GHPerson {
return Collections.unmodifiableMap(repositories);
}
/**
* Lists up all the repositories.
*
* Unlike {@link #getRepositories()}, this does not wait until all the repositories are returned.
*/
public PagedIterable<GHRepository> listRepositories() {
return new PagedIterable<GHRepository>() {
public PagedIterator<GHRepository> iterator() {
return new PagedIterator<GHRepository>(root.retrieve().asIterator("/users/" + login + "/repos", GHRepository[].class)) {
@Override
protected void wrapUp(GHRepository[] page) {
for (GHRepository c : page)
c.wrap(root);
}
};
}
};
}
/**
* Loads repository list in a pagenated fashion.
*
@@ -63,6 +82,9 @@ public abstract class GHPerson {
*
* Every {@link Iterator#next()} call results in I/O. Exceptions that occur during the processing is wrapped
* into {@link Error}.
*
* @deprecated
* Use {@link #listRepositories()}
*/
public synchronized Iterable<List<GHRepository>> iterateRepositories(final int pageSize) {
return new Iterable<List<GHRepository>>() {

View File

@@ -123,7 +123,7 @@ public class GitHub {
}
}
if (login==null)
if (login==null && encodedAuthorization!=null)
login = getMyself().getLogin();
this.login = login;
}
@@ -193,7 +193,7 @@ public class GitHub {
}
/*package*/ void requireCredential() {
if (login==null || encodedAuthorization==null)
if (login==null && encodedAuthorization==null)
throw new IllegalStateException("This operation requires a credential but none is given to the GitHub constructor");
}