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

Function bodyForWrite

pkg/cmd/pr/shared/commentable.go:352–361  ·  view source on GitHub ↗

bodyForWrite uploads the assets and reports whether the body it produced is worth writing. A failed upload that produced nothing writes nothing, since there is nothing to salvage and a comment that promises an attachment it does not have only compounds the failure. Callers must call this after ever

(opts *CommentableOptions, uploader *attachments.Uploader)

Source from the content-addressed store, hash-verified

350// Callers must call this after every prompt, since nothing that can prompt or
351// cancel may follow an upload.
352func bodyForWrite(opts *CommentableOptions, uploader *attachments.Uploader) (body string, write bool, err error) {
353 if uploader == nil {
354 return opts.Body, true, nil
355 }
356 body, uploaded, err := uploader.UploadAndAttach(context.Background(), opts.Body, opts.Assets)
357 if err != nil && uploaded == 0 {
358 return "", false, err
359 }
360 return body, true, err
361}
362
363func deleteComment(commentable Commentable, opts *CommentableOptions) error {
364 comments := commentable.CurrentUserComments()

Callers 2

createCommentFunction · 0.85
updateCommentFunction · 0.85

Calls 1

UploadAndAttachMethod · 0.80

Tested by

no test coverage detected