Skip to content

Commit

Permalink
Use GHObject as much as we can
Browse files Browse the repository at this point in the history
  • Loading branch information
kohsuke committed Feb 14, 2015
1 parent 50f43cc commit b6e48cc
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 125 deletions.
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
<plugin>
<groupId>com.infradna.tool</groupId>
<artifactId>bridge-method-injector</artifactId>
<version>1.12</version>
<version>1.14</version>
<executions>
<execution>
<goals>
Expand Down Expand Up @@ -77,7 +77,7 @@
<dependency>
<groupId>com.infradna.tool</groupId>
<artifactId>bridge-method-annotation</artifactId>
<version>1.12</version>
<version>1.14</version>

This comment has been minimized.

Copy link
@jglick

jglick Sep 13, 2017

Contributor
</dependency>
<dependency>
<groupId>org.kohsuke.stapler</groupId>
Expand Down
18 changes: 2 additions & 16 deletions src/main/java/org/kohsuke/github/GHCommitComment.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,11 @@
* @see GHCommit#listComments()
* @see GHCommit#createComment(String, String, Integer, Integer)
*/
public class GHCommitComment {
public class GHCommitComment extends GHObject {
private GHRepository owner;

String updated_at, created_at;
String body, url, html_url, commit_id;
String body, html_url, commit_id;
Integer line;
int id;
String path;
User user;

Expand All @@ -32,14 +30,6 @@ public GHRepository getOwner() {
return owner;
}

public Date getCreatedAt() {
return GitHub.parseDate(created_at);
}

public Date getUpdatedAt() {
return GitHub.parseDate(updated_at);
}

/**
* URL like 'https://github.com/kohsuke/sandbox-ant/commit/8ae38db0ea5837313ab5f39d43a6f73de3bd9000#commitcomment-1252827' to
* show this commit comment in a browser.
Expand Down Expand Up @@ -75,10 +65,6 @@ public int getLine() {
return line!=null ? line : -1;
}

public int getId() {
return id;
}

/**
* Gets the user who put this comment.
*/
Expand Down
24 changes: 1 addition & 23 deletions src/main/java/org/kohsuke/github/GHCommitStatus.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,9 @@
* @see GHRepository#getCommitStatus(String)
* @see GHCommit#getStatus()
*/
public class GHCommitStatus {
String created_at, updated_at;
public class GHCommitStatus extends GHObject {
String state;
String target_url,description;
int id;
String url;
String context;
GHUser creator;

Expand All @@ -27,14 +24,6 @@ public class GHCommitStatus {
return this;
}

public Date getCreatedAt() {
return GitHub.parseDate(created_at);
}

public Date getUpdatedAt() {
return GitHub.parseDate(updated_at);
}

public GHCommitState getState() {
for (GHCommitState s : GHCommitState.values()) {
if (s.name().equalsIgnoreCase(state))
Expand All @@ -56,17 +45,6 @@ public String getDescription() {
return description;
}

public int getId() {
return id;
}

/**
* API URL of this commit status.
*/
public String getUrl() {
return url;
}

public GHUser getCreator() {
return creator;
}
Expand Down
16 changes: 3 additions & 13 deletions src/main/java/org/kohsuke/github/GHIssue.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
* @author Eric Maupin
* @author Kohsuke Kawaguchi
*/
public class GHIssue {
public class GHIssue extends GHObject {
GitHub root;
GHRepository owner;

Expand All @@ -51,11 +51,9 @@ public class GHIssue {
protected String body;
protected List<Label> labels;
protected GHUser user;
protected String title, created_at, html_url;
protected String title, html_url;
protected GHIssue.PullRequest pull_request;
protected GHMilestone milestone;
protected String url, updated_at;
protected int id;
protected GHUser closed_by;

public static class Label {
Expand Down Expand Up @@ -117,7 +115,7 @@ public int getNumber() {
* The HTML page of this issue,
* like https://github.com/jenkinsci/jenkins/issues/100
*/
public URL getUrl() {
public URL getHtmlUrl() {

This comment has been minimized.

Copy link
@KostyaSha

KostyaSha Mar 16, 2015

Contributor

Introduced regression jenkinsci/ghprb-plugin#74 Plugins expect html url from getUrl() and now it returns api url

This comment has been minimized.

Copy link
@KostyaSha

KostyaSha Mar 16, 2015

Contributor

According to json data new naming looks right, imho this breakage is acceptable

return GitHub.parseURL(html_url);
}

Expand All @@ -136,14 +134,6 @@ public Collection<Label> getLabels() throws IOException {
return Collections.unmodifiableList(labels);
}

public Date getCreatedAt() {
return GitHub.parseDate(created_at);
}

public Date getUpdatedAt() {
return GitHub.parseDate(updated_at);
}

public Date getClosedAt() {
return GitHub.parseDate(closed_at);
}
Expand Down
22 changes: 2 additions & 20 deletions src/main/java/org/kohsuke/github/GHIssueComment.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,10 @@
*
* @author Kohsuke Kawaguchi
*/
public class GHIssueComment {
public class GHIssueComment extends GHObject {
GHIssue owner;

private String body, gravatar_id, created_at, updated_at;
private URL url;
private int id;
private String body, gravatar_id;
private GHUser user;

/*package*/ GHIssueComment wrapUp(GHIssue owner) {
Expand All @@ -59,22 +57,6 @@ public String getBody() {
return body;
}

public Date getCreatedAt() {
return GitHub.parseDate(created_at);
}

public Date getUpdatedAt() {
return GitHub.parseDate(updated_at);
}

public int getId() {
return id;
}

public URL getUrl() {
return url;
}

/**
* Gets the ID of the user who posted this comment.
*/
Expand Down
12 changes: 2 additions & 10 deletions src/main/java/org/kohsuke/github/GHMilestone.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
* @author Yusuke Kokubo
*
*/
public class GHMilestone {
public class GHMilestone extends GHObject {
GitHub root;
GHRepository owner;

GHUser creator;
private String state, due_on, title, url, created_at, description;
private String state, due_on, title, description;
private int closed_issues, open_issues, number;

public GitHub getRoot() {
Expand All @@ -38,14 +38,6 @@ public String getTitle() {
return title;
}

public String getUrl() {
return url;
}

public Date getCreatedAt() {
return GitHub.parseDate(created_at);
}

public String getDescription() {
return description;
}
Expand Down
24 changes: 11 additions & 13 deletions src/main/java/org/kohsuke/github/GHPerson.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import java.io.IOException;
import java.util.Arrays;
import java.util.Collections;
import java.util.Date;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
Expand All @@ -14,15 +15,14 @@
*
* @author Kohsuke Kawaguchi
*/
public abstract class GHPerson {
public abstract class GHPerson extends GHObject {
/*package almost final*/ GitHub root;

// core data fields that exist even for "small" user data (such as the user info in pull request)
protected String login, avatar_url, url, gravatar_id;
protected int id;
protected String login, avatar_url, gravatar_id;

// other fields (that only show up in full data)
protected String location,blog,email,name,created_at,company;
protected String location,blog,email,name,company;
protected String html_url;
protected int followers,following,public_repos,public_gists;

Expand Down Expand Up @@ -196,9 +196,14 @@ public String getLocation() throws IOException {
return location;
}

public String getCreatedAt() throws IOException {
public Date getCreatedAt() throws IOException {
populate();
return created_at;
return super.getCreatedAt();
}

public Date getUpdatedAt() throws IOException {
populate();
return super.getCreatedAt();
}

/**
Expand Down Expand Up @@ -236,13 +241,6 @@ public int getFollowingCount() throws IOException {
return following;
}

/**
* What appears to be a GitHub internal unique number that identifies this user.
*/
public int getId() {
return id;
}

public int getFollowersCount() throws IOException {
populate();
return followers;
Expand Down
29 changes: 1 addition & 28 deletions src/main/java/org/kohsuke/github/GHRelease.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,19 @@
* @see GHRepository#getReleases()
* @see GHRepository#createRelease(String)
*/
public class GHRelease {
public class GHRelease extends GHObject {
GitHub root;
GHRepository owner;

private String url;
private String html_url;
private String assets_url;
private String upload_url;
private long id;
private String tag_name;
private String target_commitish;
private String name;
private String body;
private boolean draft;
private boolean prerelease;
private Date created_at;
private Date published_at;
private String tarball_url;
private String zipball_url;
Expand All @@ -51,14 +48,6 @@ public void setBody(String body) {
this.body = body;
}

public Date getCreatedAt() {
return created_at;
}

public void setCreatedAt(Date created_at) {
this.created_at = created_at;
}

public boolean isDraft() {
return draft;
}
Expand All @@ -75,14 +64,6 @@ public void setHtmlUrl(String html_url) {
this.html_url = html_url;
}

public long getId() {
return id;
}

public void setId(long id) {
this.id = id;
}

public String getName() {
return name;
}
Expand Down Expand Up @@ -147,14 +128,6 @@ public void setUploadUrl(String upload_url) {
this.upload_url = upload_url;
}

public String getUrl() {
return url;
}

public void setUrl(String url) {
this.url = url;
}

public String getZipballUrl() {
return zipball_url;
}
Expand Down

0 comments on commit b6e48cc

Please sign in to comment.