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

Sign up
Appearance settings

Commit 2a7c1a1

Browse files
bkcsoftunknwon
authored andcommitted
More Issue-Comments API-endpoints (gogs/#3624) (#48)
* Issue-comments can be deleted * List all comments for a repo * Moar data in issue-comments
1 parent 538bef5 commit 2a7c1a1

File tree

1 file changed

+20
-5
lines changed

1 file changed

+20
-5
lines changed

‎issue_comment.go

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,14 @@ import (
1313

1414
// Comment represents a comment in commit and issue page.
1515
type Comment struct {
16-
ID int64 `json:"id"`
17-
Poster *User `json:"user"`
18-
Body string `json:"body"`
19-
Created time.Time `json:"created_at"`
20-
Updated time.Time `json:"updated_at"`
16+
ID int64 `json:"id"`
17+
HTMLURL string `json:"html_url"`
18+
PRURL string `json:"pull_request_url"`
19+
IssueURL string `json:"issue_url"`
20+
Poster *User `json:"user"`
21+
Body string `json:"body"`
22+
Created time.Time `json:"created_at"`
23+
Updated time.Time `json:"updated_at"`
2124
}
2225

2326
// ListIssueComments list comments on an issue.
@@ -26,6 +29,12 @@ func (c *Client) ListIssueComments(owner, repo string, index int64) ([]*Comment,
2629
return comments, c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/issues/%d/comments", owner, repo, index), nil, nil, &comments)
2730
}
2831

32+
// ListRepoIssueComments list comments for a given repo.
33+
func (c *Client) ListRepoIssueComments(owner, repo string) ([]*Comment, error) {
34+
comments := make([]*Comment, 0, 10)
35+
return comments, c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/issues/comments", owner, repo), nil, nil, &comments)
36+
}
37+
2938
// CreateIssueCommentOption is option when creating an issue comment.
3039
type CreateIssueCommentOption struct {
3140
Body string `json:"body" binding:"Required"`
@@ -55,3 +64,9 @@ func (c *Client) EditIssueComment(owner, repo string, index, commentID int64, op
5564
comment := new(Comment)
5665
return comment, c.getParsedResponse("PATCH", fmt.Sprintf("/repos/%s/%s/issues/%d/comments/%d", owner, repo, index, commentID), jsonHeader, bytes.NewReader(body), comment)
5766
}
67+
68+
// DeleteIssueComment deletes an issue comment.
69+
func (c *Client) DeleteIssueComment(owner, repo string, index, commentID int64) error {
70+
_, err := c.getResponse("DELETE", fmt.Sprintf("/repos/%s/%s/issues/%d/comments/%d", owner, repo, index, commentID), nil, nil)
71+
return err
72+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /