(repo string, commentID int64, msg string)
| 98 | } |
| 99 | |
| 100 | func (g *githubClient) updateComment(repo string, commentID int64, msg string) error { |
| 101 | body := map[string]string{ |
| 102 | "body": msg, |
| 103 | } |
| 104 | bodyBytes, err := json.Marshal(body) |
| 105 | if err != nil { |
| 106 | return errors.Wrap(err, "failed to marshal request body") |
| 107 | } |
| 108 | |
| 109 | url := fmt.Sprintf("%s/repos/%s/issues/comments/%d", g.apiURL, repo, commentID) |
| 110 | req, err := http.NewRequest("PATCH", url, bytes.NewReader(bodyBytes)) |
| 111 | if err != nil { |
| 112 | return errors.Wrap(err, "failed to create request") |
| 113 | } |
| 114 | req.Header.Set("Authorization", fmt.Sprintf("Bearer %s", g.token)) |
| 115 | req.Header.Set("Accept", "application/vnd.github.raw+json") |
| 116 | req.Header.Set("X-GitHub-Api-Version", "2022-11-28") |
| 117 | |
| 118 | resp, err := g.client.Do(req) |
| 119 | if err != nil { |
| 120 | return errors.Wrap(err, "failed to send request") |
| 121 | } |
| 122 | defer resp.Body.Close() |
| 123 | |
| 124 | if resp.StatusCode != http.StatusOK { |
| 125 | return errors.Errorf("failed to update comment, status code: %d", resp.StatusCode) |
| 126 | } |
| 127 | |
| 128 | return nil |
| 129 | } |
no test coverage detected