Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 898a190

Browse filesBrowse files
committed
unifying issue and pull request.
1 parent 409eda1 commit 898a190
Copy full SHA for 898a190

File tree

Expand file treeCollapse file tree

3 files changed

+41
-51
lines changed
Filter options
Expand file treeCollapse file tree

3 files changed

+41
-51
lines changed

‎src/main/java/org/kohsuke/github/GHIssue.java

Copy file name to clipboardExpand all lines: src/main/java/org/kohsuke/github/GHIssue.java
+34-7Lines changed: 34 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,36 +24,63 @@
2424

2525
package org.kohsuke.github;
2626

27+
import java.net.URL;
28+
import java.util.Collection;
29+
import java.util.Collections;
2730
import java.util.Date;
2831
import java.util.List;
32+
import java.util.Locale;
2933

3034
/**
3135
* @author Eric Maupin
3236
*/
3337
public class GHIssue {
3438
GitHub root;
3539

36-
private String gravatar_id,body,title,state,created_at;
40+
private String gravatar_id,body,title,state,created_at,updated_at,html_url;
3741
private List<String> labels;
3842
private int number,votes,comments;
43+
private int position;
3944

45+
/**
46+
* The description of this pull request.
47+
*/
48+
public String getBody() {
49+
return body;
50+
}
51+
52+
/**
53+
* ID.
54+
*/
4055
public int getNumber() {
4156
return number;
4257
}
4358

44-
public String getTitle() {
45-
return title;
59+
/**
60+
* The HTML page of this issue,
61+
* like https://github.com/jenkinsci/jenkins/issues/100
62+
*/
63+
public URL getUrl() {
64+
return GitHub.parseURL(html_url);
4665
}
4766

48-
public String getBody() {
49-
return body;
67+
public String getTitle() {
68+
return title;
5069
}
5170

5271
public GHIssueState getState() {
5372
return Enum.valueOf(GHIssueState.class, state);
5473
}
5574

56-
public Iterable<String> getLabels() {
57-
return (Iterable<String>)labels;
75+
public Collection<String> getLabels() {
76+
return Collections.unmodifiableList(labels);
77+
}
78+
79+
public Date getCreatedAt() {
80+
return GitHub.parseDate(created_at);
81+
}
82+
83+
public Date getUpdatedAt() {
84+
return GitHub.parseDate(updated_at);
5885
}
5986
}

‎src/main/java/org/kohsuke/github/GHPullRequest.java

Copy file name to clipboardExpand all lines: src/main/java/org/kohsuke/github/GHPullRequest.java
+4-41Lines changed: 4 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -33,26 +33,12 @@
3333
* @author Kohsuke Kawaguchi
3434
*/
3535
@SuppressWarnings({"UnusedDeclaration"})
36-
public class GHPullRequest {
37-
/*package almost final*/ GitHub root;
38-
39-
private String gravatar_id, closed_at, state, body, created_at, patch_url, issue_updated_at;
40-
private int number, position, comments, votes;
36+
public class GHPullRequest extends GHIssue {
37+
private String closed_at, patch_url, issue_updated_at;
4138
private GHUser issue_user, user;
4239
// labels??
4340
private GHCommitPointer base, head;
44-
private String mergeable, updated_at, html_url, title, diff_url;
45-
46-
public enum State {
47-
OPEN, CLOSED
48-
}
49-
50-
/**
51-
* The description of this pull request.
52-
*/
53-
public String getBody() {
54-
return body;
55-
}
41+
private String mergeable, diff_url;
5642

5743
/**
5844
* The URL of the patch file.
@@ -62,13 +48,6 @@ public URL getPatchUrl() {
6248
return GitHub.parseURL(patch_url);
6349
}
6450

65-
/**
66-
* ID.
67-
*/
68-
public int getNumber() {
69-
return number;
70-
}
71-
7251
/**
7352
* User who submitted a pull request.
7453
*/
@@ -103,11 +82,7 @@ public GHCommitPointer getHead() {
10382
* like https://github.com/jenkinsci/jenkins/pull/100
10483
*/
10584
public URL getUrl() {
106-
return GitHub.parseURL(html_url);
107-
}
108-
109-
public String getTitle() {
110-
return title;
85+
return super.getUrl();
11186
}
11287

11388
/**
@@ -121,16 +96,4 @@ public URL getDiffUrl() {
12196
public Date getClosedAt() {
12297
return GitHub.parseDate(closed_at);
12398
}
124-
125-
public Date getCreatedAt() {
126-
return GitHub.parseDate(created_at);
127-
}
128-
129-
public Date getUpdatedAt() {
130-
return GitHub.parseDate(updated_at);
131-
}
132-
133-
public State getState() {
134-
return State.valueOf(state.toUpperCase(Locale.ENGLISH));
135-
}
13699
}

‎src/main/java/org/kohsuke/github/GHRepository.java

Copy file name to clipboardExpand all lines: src/main/java/org/kohsuke/github/GHRepository.java
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,8 @@ public GHUser getOwner() throws IOException {
8585
return root.getUser(owner);
8686
}
8787

88-
public Iterable<GHIssue> getIssues(GHIssueState state) throws IOException {
89-
return (Iterable<GHIssue>)root.retrieve("/issues/list/" + owner + "/" + name + "/" + state.toString().toLowerCase(), JsonIssues.class).issues;
88+
public List<GHIssue> getIssues(GHIssueState state) throws IOException {
89+
return root.retrieve("/issues/list/" + owner + "/" + name + "/" + state.toString().toLowerCase(), JsonIssues.class).issues;
9090
}
9191

9292
protected String getOwnerName() {
@@ -265,7 +265,7 @@ public GHPullRequest getPullRequest(int i) throws IOException {
265265
/**
266266
* Retrieves all the pull requests of a particular state.
267267
*/
268-
public List<GHPullRequest> getPullRequests(GHPullRequest.State state) throws IOException {
268+
public List<GHPullRequest> getPullRequests(GHIssueState state) throws IOException {
269269
return root.retrieveWithAuth("/pulls/"+owner+'/'+name+"/"+state.name().toLowerCase(Locale.ENGLISH),JsonPullRequests.class).wrap(root);
270270
}
271271

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.