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

Function bodyForWrite

pkg/cmd/pr/shared/commentable.go:355–365  ·  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

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

Callers 2

createCommentFunction · 0.85
updateCommentFunction · 0.85

Calls 2

UploadAndAttachMethod · 0.80
RecordOperationsMethod · 0.80

Tested by

no test coverage detected