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

Function checkVideoReferenceImages

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

185// embeds through a reference definition. Rewriting one would produce an image
186// embed of a video, which renders as a broken image.
187func checkVideoReferenceImages(refs []attachmentRef, attachmentArgs []attachmentArg) error {
188 var paths []string
189 seen := map[int]bool{}
190 for _, r := range refs {
191 if !r.referenceStyle() || !r.isEmbed {
192 continue
193 }
194 if !attachmentArgs[r.attachmentArg].RendersAsPlayer || seen[r.attachmentArg] {
195 continue
196 }
197 seen[r.attachmentArg] = true
198 paths = append(paths, attachmentArgs[r.attachmentArg].Path)
199 }
200 if len(paths) == 0 {
201 return nil
202 }
203 return fmt.Errorf("cannot embed a video as a reference-style image: %s", strings.Join(paths, ", "))
204}
205
206// attachmentRef is one markdown reference to an attached file: the markdown
207// 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