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 0b69743

Browse filesBrowse files
committed
added comment deletion
1 parent dd54a00 commit 0b69743
Copy full SHA for 0b69743

File tree

Expand file treeCollapse file tree

2 files changed

+14
-2
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+14
-2
lines changed

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

Copy file name to clipboardExpand all lines: src/main/java/org/kohsuke/github/GHCommitComment.java
+12-1Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,21 @@ public void update(String body) throws IOException {
102102
GHCommitComment r = new Poster(owner.root,V3)
103103
.with("body",body)
104104
.withCredential()
105-
.to(String.format("/repos/%s/%s/comments/%s",owner.getOwnerName(),owner.getName(),id),GHCommitComment.class,"PATCH");
105+
.to(getApiTail(),GHCommitComment.class,"PATCH");
106106
this.body = body;
107107
}
108108

109+
/**
110+
* Deletes this comment.
111+
*/
112+
public void delete() throws IOException {
113+
new Poster(owner.root,V3).withCredential().to(getApiTail(),null,"DELETE");
114+
}
115+
116+
private String getApiTail() {
117+
return String.format("/repos/%s/%s/comments/%s",owner.getOwnerName(),owner.getName(),id);
118+
}
119+
109120

110121
GHCommitComment wrap(GHRepository owner) {
111122
this.owner = owner;

‎src/test/java/org/kohsuke/AppTest.java

Copy file name to clipboardExpand all lines: src/test/java/org/kohsuke/AppTest.java
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,13 +121,14 @@ public void testCommitComment() throws Exception {
121121
}
122122
}
123123

124-
public void testCreateCommitComment() throws Exception {
124+
public void tryCreateCommitComment() throws Exception {
125125
GitHub gitHub = GitHub.connect();
126126
GHCommit commit = gitHub.getUser("kohsuke").getRepository("sandbox-ant").getCommit("8ae38db0ea5837313ab5f39d43a6f73de3bd9000");
127127
GHCommitComment c = commit.createComment("[testing](http://kohsuse.org/)");
128128
System.out.println(c);
129129
c.update("updated text");
130130
System.out.println(c);
131+
c.delete();
131132
}
132133

133134
public void tryHook() throws Exception {

0 commit comments

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