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

Method UploadAndAttach

internal/attachments/attach.go:85–96  ·  view source on GitHub ↗

UploadAndAttach uploads assets in order and stops at the first failure. It points existing references at the URLs of successful uploads and appends only successful uploads the markdown did not reference. Assets after a failure are not attempted. It is UploadAndAttachDocuments with md as the only doc

(ctx context.Context, md, markdownDir string, assets []UserAsset)

Source from the content-addressed store, hash-verified

83// The markdown is returned unchanged when it could not be rewritten, so a
84// caller that assigns the result in place never destroys what it was given.
85func (u *Uploader) UploadAndAttach(ctx context.Context, md, markdownDir string, assets []UserAsset) (string, UploadResult, error) {
86 results, err := u.UploadAndAttachDocuments(ctx, []Document{{Markdown: md, Dir: markdownDir}}, assets)
87 if len(results) == 0 {
88 return md, UploadResult{}, err
89 }
90 r := results[0]
91 return r.Markdown, UploadResult{
92 Uploaded: len(r.Uploaded),
93 AppendOperations: r.AppendOperations,
94 ReplaceOperations: r.ReplaceOperations,
95 }, err
96}
97
98// UploadAndAttachDocuments attaches one set of files to several documents at
99// once. It uploads each file once, in order, and stops at the first failure.

Callers 12

createRunFunction · 0.95
TestNewUploaderFunction · 0.95
editRunFunction · 0.95
editRunFunction · 0.95
editRunFunction · 0.95
bodyForWriteFunction · 0.80
submitPRFunction · 0.80

Calls 1