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

Method UpdateRef

github/git_refs.go:148–171  ·  view source on GitHub ↗

UpdateRef updates an existing ref in a repository. GitHub API docs: https://docs.github.com/rest/git/refs?apiVersion=2022-11-28#update-a-reference meta:operation PATCH /repos/{owner}/{repo}/git/refs/{ref}

(ctx context.Context, owner, repo, ref string, updateRef UpdateRef)

Source from the content-addressed store, hash-verified

146//
147//meta:operation PATCH /repos/{owner}/{repo}/git/refs/{ref}
148func (s *GitService) UpdateRef(ctx context.Context, owner, repo, ref string, updateRef UpdateRef) (*Reference, *Response, error) {
149 if ref == "" {
150 return nil, nil, errors.New("ref must be provided")
151 }
152
153 if updateRef.SHA == "" {
154 return nil, nil, errors.New("sha must be provided")
155 }
156
157 refPath := strings.TrimPrefix(ref, "refs/")
158 u := fmt.Sprintf("repos/%v/%v/git/refs/%v", owner, repo, refURLEscape(refPath))
159 req, err := s.client.NewRequest(ctx, "PATCH", u, updateRef)
160 if err != nil {
161 return nil, nil, err
162 }
163
164 var r *Reference
165 resp, err := s.client.Do(req, &r)
166 if err != nil {
167 return nil, resp, err
168 }
169
170 return r, resp, nil
171}
172
173// DeleteRef deletes a ref from a repository.
174//

Callers 3

pushCommitFunction · 0.80
TestGitService_UpdateRefFunction · 0.80

Calls 3

refURLEscapeFunction · 0.85
NewRequestMethod · 0.80
DoMethod · 0.45

Tested by 2

TestGitService_UpdateRefFunction · 0.64