Skip to content

Commit

Permalink
Merge pull request #143
Browse files Browse the repository at this point in the history
  • Loading branch information
kohsuke committed Feb 14, 2015
2 parents 3b6ca30 + c6fc03c commit 609f532
Show file tree
Hide file tree
Showing 18 changed files with 164 additions and 354 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>
</dependency>
<dependency>
<groupId>org.kohsuke.stapler</groupId>
Expand Down
23 changes: 1 addition & 22 deletions src/main/java/org/kohsuke/github/GHAsset.java
Original file line number Diff line number Diff line change
@@ -1,26 +1,21 @@
package org.kohsuke.github;

import java.io.IOException;
import java.util.Date;

/**
* Asset in a release.
*
* @see GHRelease#getAssets()
*/
public class GHAsset {
public class GHAsset extends GHObject {
GitHub root;
GHRepository owner;
private String url;
private String id;
private String name;
private String label;
private String state;
private String content_type;
private long size;
private long download_count;
private Date created_at;
private Date updated_at;
private String browser_download_url;

public String getContentType() {
Expand All @@ -32,18 +27,10 @@ public void setContentType(String contentType) throws IOException {
this.content_type = contentType;
}

public Date getCreatedAt() {
return created_at;
}

public long getDownloadCount() {
return download_count;
}

public String getId() {
return id;
}

public String getLabel() {
return label;
}
Expand Down Expand Up @@ -73,14 +60,6 @@ public String getState() {
return state;
}

public Date getUpdatedAt() {
return updated_at;
}

public String getUrl() {
return url;
}

public String getBrowserDownloadUrl() {
return browser_download_url;
}
Expand Down
18 changes: 1 addition & 17 deletions src/main/java/org/kohsuke/github/GHAuthorization.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* @see GitHub#createToken(Collection, String, String)
* @see http://developer.github.com/v3/oauth/#create-a-new-authorization
*/
public class GHAuthorization {
public class GHAuthorization extends GHObject {
public static final String USER = "user";
public static final String USER_EMAIL = "user:email";
public static final String USER_FOLLOW = "user:follow";
Expand All @@ -33,24 +33,16 @@ public class GHAuthorization {
public static final String ADMIN_KEY = "admin:public_key";

private GitHub root;
private int id;
private String url;
private List<String> scopes;
private String token;
private App app;
private String note;
private String note_url;
private String updated_at;
private String created_at;

public GitHub getRoot() {
return root;
}

public int getId() {
return id;
}

public List<String> getScopes() {
return scopes;
}
Expand Down Expand Up @@ -78,14 +70,6 @@ public String getNote() {
public URL getNoteUrl(){
return GitHub.parseURL(note_url);
}

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

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

/*package*/ GHAuthorization wrap(GitHub root) {
this.root = root;
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
2 changes: 1 addition & 1 deletion src/main/java/org/kohsuke/github/GHDeployment.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import java.net.URL;

public class GHDeployment extends Identifiable {
public class GHDeployment extends GHObject {
private GHRepository owner;
private GitHub root;
protected String sha;
Expand Down
72 changes: 36 additions & 36 deletions src/main/java/org/kohsuke/github/GHDeploymentStatus.java
Original file line number Diff line number Diff line change
@@ -1,36 +1,36 @@
package org.kohsuke.github;

import java.net.URL;

public class GHDeploymentStatus extends Identifiable {
private GHRepository owner;
private GitHub root;
protected GHUser creator;
protected String state;
protected String description;
protected String target_url;
protected String deployment_url;
protected String repository_url;
public GHDeploymentStatus wrap(GHRepository owner) {
this.owner = owner;
this.root = owner.root;
if(creator != null) creator.wrapUp(root);
return this;
}
public URL getTargetUrl() {
return GitHub.parseURL(target_url);
}

public URL getDeploymentUrl() {
return GitHub.parseURL(deployment_url);
}

public URL getRepositoryUrl() {
return GitHub.parseURL(repository_url);
}
public GHDeploymentState getState() {
return GHDeploymentState.valueOf(state.toUpperCase());
}


}
package org.kohsuke.github;

import java.net.URL;

public class GHDeploymentStatus extends GHObject {
private GHRepository owner;
private GitHub root;
protected GHUser creator;
protected String state;
protected String description;
protected String target_url;
protected String deployment_url;
protected String repository_url;
public GHDeploymentStatus wrap(GHRepository owner) {
this.owner = owner;
this.root = owner.root;
if(creator != null) creator.wrapUp(root);
return this;
}
public URL getTargetUrl() {
return GitHub.parseURL(target_url);
}

public URL getDeploymentUrl() {
return GitHub.parseURL(deployment_url);
}

public URL getRepositoryUrl() {
return GitHub.parseURL(repository_url);
}
public GHDeploymentState getState() {
return GHDeploymentState.valueOf(state.toUpperCase());
}


}
60 changes: 30 additions & 30 deletions src/main/java/org/kohsuke/github/GHDeploymentStatusBuilder.java
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
package org.kohsuke.github;

import java.io.IOException;

public class GHDeploymentStatusBuilder {
private final Requester builder;
private GHRepository repo;
private int deploymentId;

public GHDeploymentStatusBuilder(GHRepository repo, int deploymentId, GHDeploymentState state) {
this.repo = repo;
this.deploymentId = deploymentId;
this.builder = new Requester(repo.root);
this.builder.with("state",state.toString().toLowerCase());
}

public GHDeploymentStatusBuilder description(String description) {
this.builder.with("description",description);
return this;
}

public GHDeploymentStatusBuilder targetUrl(String targetUrl) {
this.builder.with("target_url",targetUrl);
return this;
}

public GHDeploymentStatus create() throws IOException {
return builder.to(repo.getApiTailUrl("deployments")+"/"+deploymentId+"/statuses",GHDeploymentStatus.class).wrap(repo);
}
}
package org.kohsuke.github;

import java.io.IOException;

public class GHDeploymentStatusBuilder {
private final Requester builder;
private GHRepository repo;
private int deploymentId;

public GHDeploymentStatusBuilder(GHRepository repo, int deploymentId, GHDeploymentState state) {
this.repo = repo;
this.deploymentId = deploymentId;
this.builder = new Requester(repo.root);
this.builder.with("state",state.toString().toLowerCase());
}

public GHDeploymentStatusBuilder description(String description) {
this.builder.with("description",description);
return this;
}

public GHDeploymentStatusBuilder targetUrl(String targetUrl) {
this.builder.with("target_url",targetUrl);
return this;
}

public GHDeploymentStatus create() throws IOException {
return builder.to(repo.getApiTailUrl("deployments")+"/"+deploymentId+"/statuses",GHDeploymentStatus.class).wrap(repo);
}
}
Loading

0 comments on commit 609f532

Please sign in to comment.