UpdateBranchProtection updates the protection of a given branch. Note: the branch name is URL path escaped for you. See: https://pkg.go.dev/net/url#PathEscape . GitHub API docs: https://docs.github.com/rest/branches/branch-protection?apiVersion=2022-11-28#update-branch-protection meta:operation P
(ctx context.Context, owner, repo, branch string, preq *ProtectionRequest)
| 1599 | // |
| 1600 | //meta:operation PUT /repos/{owner}/{repo}/branches/{branch}/protection |
| 1601 | func (s *RepositoriesService) UpdateBranchProtection(ctx context.Context, owner, repo, branch string, preq *ProtectionRequest) (*Protection, *Response, error) { |
| 1602 | u := fmt.Sprintf("repos/%v/%v/branches/%v/protection", owner, repo, url.PathEscape(branch)) |
| 1603 | req, err := s.client.NewRequest(ctx, "PUT", u, preq) |
| 1604 | if err != nil { |
| 1605 | return nil, nil, err |
| 1606 | } |
| 1607 | |
| 1608 | req.Header.Set("Accept", mediaTypeRequiredApprovingReviewsPreview) |
| 1609 | |
| 1610 | var p *Protection |
| 1611 | resp, err := s.client.Do(req, &p) |
| 1612 | if err != nil { |
| 1613 | return nil, resp, err |
| 1614 | } |
| 1615 | |
| 1616 | return p, resp, nil |
| 1617 | } |
| 1618 | |
| 1619 | // RemoveBranchProtection removes the protection of a given branch. |
| 1620 | // |