mirror of
https://github.com/jlengrand/github-api.git
synced 2026-04-04 00:11:24 +00:00
Clean up GHIssue and GHPullRequest and make them relevant to api v3.
Added SmallUser representing reference to user. Added DetailedPullRequest - when retrieving pull request by id, it has more attributes then pull requests obtained by GHRepository.getPullRequests()
This commit is contained in:
@@ -42,15 +42,29 @@ import java.util.Locale;
|
||||
public class GHIssue {
|
||||
GitHub root;
|
||||
GHRepository owner;
|
||||
|
||||
private String gravatar_id,body,title,state,created_at,updated_at,html_url;
|
||||
|
||||
// API v3
|
||||
private GHSmallUser assignee;
|
||||
private String state;
|
||||
private int number;
|
||||
private String closed_at;
|
||||
private int comments;
|
||||
private String body;
|
||||
private List<String> labels;
|
||||
private int number,votes,comments;
|
||||
private int position;
|
||||
private GHSmallUser user;
|
||||
private String title, created_at, html_url;
|
||||
private GHIssue.PullRequest pull_request;
|
||||
// GHIssue milestone
|
||||
private String url, updated_at;
|
||||
private int id;
|
||||
private GHSmallUser closed_by;
|
||||
|
||||
/*package*/ GHIssue wrap(GHRepository owner) {
|
||||
this.owner = owner;
|
||||
this.root = owner.root;
|
||||
if(assignee != null) assignee.wrapUp(root);
|
||||
if(user != null) user.wrapUp(root);
|
||||
if(closed_by != null) closed_by.wrapUp(root);
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -112,6 +126,10 @@ public class GHIssue {
|
||||
return GitHub.parseDate(updated_at);
|
||||
}
|
||||
|
||||
public Date getClosedAt() {
|
||||
return GitHub.parseDate(closed_at);
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the issue by adding a comment.
|
||||
*/
|
||||
@@ -182,4 +200,47 @@ public class GHIssue {
|
||||
private String getApiRoute() {
|
||||
return "/repos/"+owner.getOwnerName()+"/"+owner.getName()+"/issues/"+number;
|
||||
}
|
||||
|
||||
public GHSmallUser getAssignee() {
|
||||
return assignee;
|
||||
}
|
||||
|
||||
/**
|
||||
* User who submitted the issue.
|
||||
*/
|
||||
public GHSmallUser getUser() {
|
||||
return user;
|
||||
}
|
||||
|
||||
public GHSmallUser getClosedBy() {
|
||||
if(!"closed".equals(state)) return null;
|
||||
if(closed_by != null) return closed_by;
|
||||
|
||||
//TODO closed_by = owner.getIssue(number).getClosed_by();
|
||||
return closed_by;
|
||||
}
|
||||
|
||||
public int getCommentsCount(){
|
||||
return comments;
|
||||
}
|
||||
|
||||
public PullRequest getPullRequest() {
|
||||
return pull_request;
|
||||
}
|
||||
|
||||
public class PullRequest{
|
||||
private String diff_url, patch_url, html_url;
|
||||
|
||||
public URL getDiffUrl() {
|
||||
return GitHub.parseURL(diff_url);
|
||||
}
|
||||
|
||||
public URL getPatchUrl() {
|
||||
return GitHub.parseURL(patch_url);
|
||||
}
|
||||
|
||||
public URL getUrl() {
|
||||
return GitHub.parseURL(html_url);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user