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

Function bodyForWrite

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

346// Callers must call this after every prompt, since nothing that can prompt or
347// cancel may follow an upload.
348func bodyForWrite(opts *CommentableOptions, uploader *attachments.Uploader) (body string, write bool, err error) {
349 if uploader == nil {
350 return opts.Body, true, nil
351 }
352 body, uploadResult, err := uploader.UploadAndAttach(context.Background(), opts.Body, opts.BodyDir, opts.Assets)
353 opts.AttachEvent.RecordOperations(uploadResult)
354 if err != nil && uploadResult.Uploaded == 0 {
355 return "", false, err
356 }
357 return body, true, err
358}
359
360func deleteComment(commentable Commentable, opts *CommentableOptions) error {
361 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