Skip to content

Commit

Permalink
Merge pull request #201
Browse files Browse the repository at this point in the history
  • Loading branch information
kohsuke committed Jul 17, 2015
2 parents 340fb3f + 025806f commit 202cff5
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 4 deletions.
13 changes: 10 additions & 3 deletions src/main/java/org/kohsuke/github/GHIssue.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@

package org.kohsuke.github;

import com.infradna.tool.bridge_method_injector.WithBridgeMethods;

import java.io.IOException;
import java.net.URL;
import java.util.Collection;
Expand Down Expand Up @@ -140,9 +142,14 @@ public URL getApiURL(){

/**
* Updates the issue by adding a comment.
*
* @return
* Newly posted comment.
*/
public void comment(String message) throws IOException {
new Requester(root).with("body",message).to(getIssuesApiRoute() + "/comments");
@WithBridgeMethods(void.class)
public GHIssueComment comment(String message) throws IOException {
GHIssueComment r = new Requester(root).with("body",message).to(getIssuesApiRoute() + "/comments", GHIssueComment.class);
return r.wrapUp(this);
}

private void edit(String key, Object value) throws IOException {
Expand Down Expand Up @@ -176,7 +183,7 @@ public void setBody(String body) throws IOException {
}

public void assignTo(GHUser user) throws IOException {
editIssue("assignee",user.getLogin());
editIssue("assignee", user.getLogin());
}

public void setLabels(String... labels) throws IOException {
Expand Down
20 changes: 19 additions & 1 deletion src/main/java/org/kohsuke/github/GHIssueComment.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@

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

/**
* Comment to the issue
Expand Down Expand Up @@ -79,4 +78,23 @@ public GHUser getUser() throws IOException {
public URL getHtmlUrl() {
return null;
}

/**
* Updates the body of the issue comment.
*/
public void update(String body) throws IOException {
new Requester(owner.root).with("body", body).method("PATCH").to(getApiRoute(), GHIssueComment.class);
this.body = body;
}

/**
* Deletes this issue comment.
*/
public void delete() throws IOException {
new Requester(owner.root).method("DELETE").to(getApiRoute());
}

private String getApiRoute() {
return "/repos/"+owner.getRepository().getOwnerName()+"/"+owner.getRepository().getName()+"/issues/comments/" + id;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ protected String getApiRoute() {
*/
public void update(String body) throws IOException {
new Requester(owner.root).method("PATCH").with("body", body).to(getApiRoute(),this);
this.body = body;
}

/**
Expand Down

0 comments on commit 202cff5

Please sign in to comment.