CreateRef creates a new ref in a repository. GitHub API docs: https://docs.github.com/rest/git/refs?apiVersion=2022-11-28#create-a-reference meta:operation POST /repos/{owner}/{repo}/git/refs
(ctx context.Context, owner, repo string, ref CreateRef)
| 114 | // |
| 115 | //meta:operation POST /repos/{owner}/{repo}/git/refs |
| 116 | func (s *GitService) CreateRef(ctx context.Context, owner, repo string, ref CreateRef) (*Reference, *Response, error) { |
| 117 | if ref.Ref == "" { |
| 118 | return nil, nil, errors.New("ref must be provided") |
| 119 | } |
| 120 | |
| 121 | if ref.SHA == "" { |
| 122 | return nil, nil, errors.New("sha must be provided") |
| 123 | } |
| 124 | |
| 125 | // ensure the 'refs/' prefix is present |
| 126 | ref.Ref = "refs/" + strings.TrimPrefix(ref.Ref, "refs/") |
| 127 | |
| 128 | u := fmt.Sprintf("repos/%v/%v/git/refs", owner, repo) |
| 129 | req, err := s.client.NewRequest(ctx, "POST", u, ref) |
| 130 | if err != nil { |
| 131 | return nil, nil, err |
| 132 | } |
| 133 | |
| 134 | var r *Reference |
| 135 | resp, err := s.client.Do(req, &r) |
| 136 | if err != nil { |
| 137 | return nil, resp, err |
| 138 | } |
| 139 | |
| 140 | return r, resp, nil |
| 141 | } |
| 142 | |
| 143 | // UpdateRef updates an existing ref in a repository. |
| 144 | // |