diff --git a/pulls.go b/pulls.go index c5a4cb9..762d5ee 100644 --- a/pulls.go +++ b/pulls.go @@ -69,11 +69,21 @@ type PullRequestComment struct { Author *User `json:"author"` Path string `json:"path"` Position int `json:"position"` + Line int `json:"line"` + Side string `json:"side"` CommitID string `json:"commit_id"` CreatedAt time.Time `json:"created_at"` UpdatedAt time.Time `json:"updated_at"` } +type CreatePullRequestInlineCommentOptions struct { + Body string `json:"body"` + Path string `json:"path"` + Line int `json:"line"` + Side string `json:"side"` + CommitID string `json:"commit_id,omitempty"` +} + type PullRequestReview struct { ID int64 `json:"id"` Body string `json:"body"` @@ -245,6 +255,15 @@ func (c *Client) CreatePullRequestComment(ctx context.Context, owner, repo strin return &comment, nil } +func (c *Client) CreatePullRequestInlineComment(ctx context.Context, owner, repo string, number int, opts CreatePullRequestInlineCommentOptions) (*PullRequestComment, error) { + var comment PullRequestComment + err := c.doRequest(ctx, http.MethodPost, fmt.Sprintf("/repos/%s/%s/pulls/%d/comments", owner, repo, number), opts, &comment) + if err != nil { + return nil, err + } + return &comment, nil +} + func (c *Client) UpdatePullRequestComment(ctx context.Context, owner, repo string, commentID string, body string) (*PullRequestComment, error) { var comment PullRequestComment err := c.doRequest(ctx, http.MethodPatch, fmt.Sprintf("/repos/%s/%s/pulls/comments/%s", owner, repo, commentID), map[string]string{"body": body}, &comment)