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

Method Run

tools/metadata/main.go:85–121  ·  view source on GitHub ↗
(root *rootCmd)

Source from the content-addressed store, hash-verified

83}
84
85func (c *updateOpenAPICmd) Run(root *rootCmd) error {
86 ctx := context.Background()
87 if c.ValidateGithub && c.Ref != "main" {
88 return errors.New("--validate and --ref are mutually exclusive")
89 }
90 filename, opsFile, err := root.opsFile()
91 if err != nil {
92 return err
93 }
94 origOps := make([]*operation, len(opsFile.OpenapiOps))
95 copy(origOps, opsFile.OpenapiOps)
96 for i := range origOps {
97 origOps[i] = origOps[i].clone()
98 }
99 client, err := githubClient(root.GithubURL, root.UploadURL)
100 if err != nil {
101 return err
102 }
103 ref := c.Ref
104 if c.ValidateGithub {
105 ref = opsFile.GitCommit
106 if ref == "" {
107 return errors.New("openapi_operations.yaml does not have an openapi_commit field")
108 }
109 }
110 err = opsFile.updateFromGithub(ctx, client, ref)
111 if err != nil {
112 return err
113 }
114 if !c.ValidateGithub {
115 return opsFile.saveFile(filename)
116 }
117 if !operationsEqual(origOps, opsFile.OpenapiOps) {
118 return errors.New("openapi_operations.yaml does not match the OpenAPI descriptions in github.com/github/rest-api-description")
119 }
120 return nil
121}
122
123type formatCmd struct{}
124

Callers

nothing calls this directly

Calls 6

githubClientFunction · 0.85
operationsEqualFunction · 0.85
opsFileMethod · 0.80
cloneMethod · 0.80
updateFromGithubMethod · 0.80
saveFileMethod · 0.80

Tested by

no test coverage detected