MCPcopy
hub / github.com/cli/cli / getFilesToAdd

Function getFilesToAdd

pkg/cmd/gist/edit/edit.go:414–430  ·  view source on GitHub ↗
(file string, content []byte)

Source from the content-addressed store, hash-verified

412}
413
414func getFilesToAdd(file string, content []byte) (map[string]*gistFileToUpdate, error) {
415 if shared.IsBinaryContents(content) {
416 return nil, fmt.Errorf("failed to upload %s: binary file not supported", file)
417 }
418
419 if len(content) == 0 {
420 return nil, errors.New("file contents cannot be empty")
421 }
422
423 filename := filepath.Base(file)
424 return map[string]*gistFileToUpdate{
425 filename: {
426 NewFilename: filename,
427 Content: string(content),
428 },
429 }, nil
430}
431
432func getFilesToRemove(gist gistToUpdate, filename string) (map[string]*gistFileToUpdate, error) {
433 if _, found := gist.Files[filename]; !found {

Callers 2

Test_getFilesToAddFunction · 0.85
editRunFunction · 0.85

Calls 3

IsBinaryContentsFunction · 0.92
BaseMethod · 0.80
ErrorfMethod · 0.65

Tested by 1

Test_getFilesToAddFunction · 0.68