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

Function attachmentArgsByPath

internal/attachments/references.go:326–342  ·  view source on GitHub ↗

attachmentArgsByPath indexes the attached files by absolute path, ready for attachmentArgForDestination to look one up. An argument with no URL is indexed too, so validation can run before anything has uploaded.

(attachmentArgs []attachmentArg)

Source from the content-addressed store, hash-verified

324// attachmentArgForDestination to look one up. An argument with no URL is
325// indexed too, so validation can run before anything has uploaded.
326func attachmentArgsByPath(attachmentArgs []attachmentArg) (map[string]int, error) {
327 byPath := make(map[string]int, len(attachmentArgs))
328 for i, a := range attachmentArgs {
329 if a.Path == "" {
330 continue
331 }
332 abs, err := filepath.Abs(a.Path)
333 if err != nil {
334 return nil, err
335 }
336 if _, dup := byPath[abs]; dup {
337 continue
338 }
339 byPath[abs] = i
340 }
341 return byPath, nil
342}
343
344// attachmentArgForDestination is where the two halves of this package meet: it
345// takes a markdown destination and answers which attached file, if any, it

Callers 1

scanMarkdownRefsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected