MCPcopy Index your code
hub / github.com/bytebase/bytebase / updateComment

Method updateComment

action/github/api.go:100–129  ·  view source on GitHub ↗
(repo string, commentID int64, msg string)

Source from the content-addressed store, hash-verified

98}
99
100func (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}

Callers 1

upsertCommentFunction · 0.80

Calls 4

DoMethod · 0.80
ErrorfMethod · 0.80
CloseMethod · 0.65
SetMethod · 0.45

Tested by

no test coverage detected