MCPcopy Create free account
hub / github.com/cli/cli / Update

Method Update

pkg/cmd/issue/artifact/client/client.go:182–205  ·  view source on GitHub ↗

Update sends only the fields it changes, since the API keeps any field a request leaves out.

(repo ghrepo.Interface, issueNumber int, number int, name, body *string)

Source from the content-addressed store, hash-verified

180// Update sends only the fields it changes, since the API keeps any field a
181// request leaves out.
182func (c *artifactClient) Update(repo ghrepo.Interface, issueNumber int, number int, name, body *string) (*Artifact, error) {
183 u, err := safeurl.JoinPath("repos", repo.RepoOwner(), repo.RepoName(), "issues", strconv.Itoa(issueNumber), "artifacts", strconv.Itoa(number))
184 if err != nil {
185 return nil, err
186 }
187
188 // omitempty leaves out a nil field, and still sends an empty string.
189 payload, err := json.Marshal(struct {
190 Name *string `json:"name,omitempty"`
191 Body *string `json:"body,omitempty"`
192 }{
193 Name: name,
194 Body: body,
195 })
196 if err != nil {
197 return nil, err
198 }
199
200 var artifact Artifact
201 if err := c.apiClient.REST(repo.RepoHost(), "PATCH", u.String(), bytes.NewReader(payload), &artifact); err != nil {
202 return nil, err
203 }
204 return &artifact, nil
205}

Callers

nothing calls this directly

Calls 6

JoinPathFunction · 0.92
RepoOwnerMethod · 0.65
RepoNameMethod · 0.65
RESTMethod · 0.65
RepoHostMethod · 0.65
StringMethod · 0.65

Tested by

no test coverage detected