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

Method CreateFile

github/repos_contents.go:256–270  ·  view source on GitHub ↗

CreateFile creates a new file in a repository at the given path and returns the commit and file metadata. GitHub API docs: https://docs.github.com/rest/repos/contents?apiVersion=2022-11-28#create-or-update-file-contents meta:operation PUT /repos/{owner}/{repo}/contents/{path}

(ctx context.Context, owner, repo, path string, opts *RepositoryContentFileOptions)

Source from the content-addressed store, hash-verified

254//
255//meta:operation PUT /repos/{owner}/{repo}/contents/{path}
256func (s *RepositoriesService) CreateFile(ctx context.Context, owner, repo, path string, opts *RepositoryContentFileOptions) (*RepositoryContentResponse, *Response, error) {
257 u := fmt.Sprintf("repos/%v/%v/contents/%v", owner, repo, path)
258 req, err := s.client.NewRequest(ctx, "PUT", u, opts)
259 if err != nil {
260 return nil, nil, err
261 }
262
263 var createResponse *RepositoryContentResponse
264 resp, err := s.client.Do(req, &createResponse)
265 if err != nil {
266 return nil, resp, err
267 }
268
269 return createResponse, resp, nil
270}
271
272// UpdateFile updates a file in a repository at the given path and returns the
273// commit and file metadata. Requires the blob SHA of the file being updated.

Callers 3

mainFunction · 0.80

Calls 2

NewRequestMethod · 0.80
DoMethod · 0.45