Skip to content
This repository was archived by the owner on Jul 31, 2025. It is now read-only.

Commit cce02ae

Browse files
committed
Add delete and update for GHIssueComment
1 parent dd3e739 commit cce02ae

File tree

3 files changed

+23
-2
lines changed

3 files changed

+23
-2
lines changed

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,9 @@ public URL getApiURL(){
141141
/**
142142
* Updates the issue by adding a comment.
143143
*/
144-
public void comment(String message) throws IOException {
145-
new Requester(root).with("body",message).to(getIssuesApiRoute() + "/comments");
144+
public GHIssueComment comment(String message) throws IOException {
145+
GHIssueComment r = new Requester(root).with("body",message).to(getIssuesApiRoute() + "/comments", GHIssueComment.class);
146+
return r.wrapUp(this);
146147
}
147148

148149
private void edit(String key, Object value) throws IOException {

src/main/java/org/kohsuke/github/GHIssueComment.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,4 +79,23 @@ public GHUser getUser() throws IOException {
7979
public URL getHtmlUrl() {
8080
return null;
8181
}
82+
83+
/**
84+
* Updates the body of the issue comment.
85+
*/
86+
public void update(String body) throws IOException {
87+
new Requester(owner.root).with("body", body).method("PATCH").to(getCommentApiTail(), GHIssueComment.class);
88+
this.body = body;
89+
}
90+
91+
/**
92+
* Deletes this issue comment.
93+
*/
94+
public void delete() throws IOException {
95+
new Requester(owner.root).method("DELETE").to(getCommentApiTail());
96+
}
97+
98+
private String getCommentApiTail() {
99+
return "/repos/"+owner.getRepository().getOwnerName()+"/"+owner.getRepository().getName()+"/issues/comments/" + id;
100+
}
82101
}

src/main/java/org/kohsuke/github/GHPullRequestReviewComment.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ protected String getApiRoute() {
9494
*/
9595
public void update(String body) throws IOException {
9696
new Requester(owner.root).method("PATCH").with("body", body).to(getApiRoute(),this);
97+
this.body = body;
9798
}
9899

99100
/**

0 commit comments

Comments
 (0)