MCPcopy Index your code
hub / github.com/google/go-github / loadDescription

Method loadDescription

tools/metadata/openapi.go:58–82  ·  view source on GitHub ↗
(ctx context.Context, client *github.Client, gitRef string)

Source from the content-addressed store, hash-verified

56}
57
58func (o *openapiFile) loadDescription(ctx context.Context, client *github.Client, gitRef string) error {
59 contents, resp, err := client.Repositories.DownloadContents(
60 ctx,
61 descriptionsOwnerName,
62 descriptionsRepoName,
63 o.filename,
64 &github.RepositoryContentGetOptions{Ref: gitRef},
65 )
66 if err != nil {
67 return err
68 }
69 if resp.StatusCode != 200 {
70 return fmt.Errorf("unexpected status code: %v", resp.Status)
71 }
72 b, err := io.ReadAll(contents)
73 if err != nil {
74 return err
75 }
76 err = contents.Close()
77 if err != nil {
78 return err
79 }
80 o.description, err = openapi3.NewLoader().LoadFromData(b)
81 return err
82}
83
84var dirPatterns = []*regexp.Regexp{
85 regexp.MustCompile(`^(?P<plan>api\.github\.com)(-(?P<major>\d+)\.(?P<minor>\d+))?$`),

Callers 1

getDescriptionsFunction · 0.80

Calls 2

DownloadContentsMethod · 0.80
CloseMethod · 0.80

Tested by

no test coverage detected