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

Function loadContent

pkg/cmd/repo/read-file/read_file.go:216–227  ·  view source on GitHub ↗

loadContent fetches the raw file bytes when the Contents API did not return them inline. The API only omits inline content for large files, which it marks with a "none" encoding; everything else (including empty files) comes back base64-encoded, so there is nothing to fetch.

(httpClient *http.Client, repo ghrepo.Interface, file *repoFile, ref string)

Source from the content-addressed store, hash-verified

214// The API only omits inline content for large files, which it marks with a "none" encoding;
215// everything else (including empty files) comes back base64-encoded, so there is nothing to fetch.
216func loadContent(httpClient *http.Client, repo ghrepo.Interface, file *repoFile, ref string) error {
217 if file.Encoding != "none" {
218 return nil
219 }
220
221 raw, err := fetchRawFile(httpClient, repo, file.Path, ref)
222 if err != nil {
223 return err
224 }
225 file.Content = raw
226 return nil
227}
228
229// lstatResult captures the subset of output-path information the command needs,
230// determined without following a symlink at the path.

Callers 1

readFileRunFunction · 0.85

Calls 1

fetchRawFileFunction · 0.85

Tested by

no test coverage detected