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)
| 146 | // |
| 147 | //meta:operation PATCH /repos/{owner}/{repo}/git/refs/{ref} |
| 148 | func (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 | // |