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

Function attachmentArgsByPath

internal/attachments/references.go:340–356  ·  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

338// attachmentArgForDestination to look one up. An argument with no URL is
339// indexed too, so validation can run before anything has uploaded.
340func attachmentArgsByPath(attachmentArgs []attachmentArg) (map[string]int, error) {
341 byPath := make(map[string]int, len(attachmentArgs))
342 for i, a := range attachmentArgs {
343 if a.Path == "" {
344 continue
345 }
346 abs, err := filepath.Abs(a.Path)
347 if err != nil {
348 return nil, err
349 }
350 if _, dup := byPath[abs]; dup {
351 continue
352 }
353 byPath[abs] = i
354 }
355 return byPath, nil
356}
357
358// attachmentArgForDestination is where the two halves of this package meet: it
359// 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