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

Function checkVideoReferenceImages

internal/attachments/references.go:201–218  ·  view source on GitHub ↗

checkVideoReferenceImages returns an error naming every video the markdown embeds through a reference definition. Rewriting one would produce an image embed of a video, which renders as a broken image.

(refs []attachmentRef, attachmentArgs []attachmentArg)

Source from the content-addressed store, hash-verified

199// embeds through a reference definition. Rewriting one would produce an image
200// embed of a video, which renders as a broken image.
201func checkVideoReferenceImages(refs []attachmentRef, attachmentArgs []attachmentArg) error {
202 var paths []string
203 seen := map[int]bool{}
204 for _, r := range refs {
205 if !r.referenceStyle() || !r.isEmbed {
206 continue
207 }
208 if !attachmentArgs[r.attachmentArg].RendersAsPlayer || seen[r.attachmentArg] {
209 continue
210 }
211 seen[r.attachmentArg] = true
212 paths = append(paths, attachmentArgs[r.attachmentArg].Path)
213 }
214 if len(paths) == 0 {
215 return nil
216 }
217 return fmt.Errorf("cannot embed a video as a reference-style image: %s", strings.Join(paths, ", "))
218}
219
220// attachmentRef is one markdown reference to an attached file: the markdown
221// half of this package, paired to an argument by attachmentArgForDestination.

Callers 1

newAttachableMarkdownFunction · 0.85

Calls 3

referenceStyleMethod · 0.80
JoinMethod · 0.80
ErrorfMethod · 0.65

Tested by

no test coverage detected