(ctx context.Context, installationID, repoID int64, remote, branch string)
| 157 | } |
| 158 | |
| 159 | func (g *githubClient) DeleteBranch(ctx context.Context, installationID, repoID int64, remote, branch string) error { |
| 160 | client := g.InstallationClient(installationID, &repoID) |
| 161 | org, repo, ok := gitutil.SplitGithubRemote(remote) |
| 162 | if !ok { |
| 163 | return fmt.Errorf("invalid Github remote %q", remote) |
| 164 | } |
| 165 | _, err := client.Git.DeleteRef(ctx, org, repo, "heads/"+branch) |
| 166 | if err != nil { |
| 167 | var ghErr *github.ErrorResponse |
| 168 | if errors.As(err, &ghErr) && (ghErr.Response.StatusCode == http.StatusNotFound || ghErr.Response.StatusCode == http.StatusUnprocessableEntity) { |
| 169 | return ErrBranchNotFound |
| 170 | } |
| 171 | return fmt.Errorf("failed to delete branch %q: %w", branch, err) |
| 172 | } |
| 173 | return nil |
| 174 | } |
| 175 | |
| 176 | func (g *githubClient) CreateManagedRepo(ctx context.Context, name string, autoInit bool) (*github.Repository, error) { |
| 177 | repoName := fmt.Sprintf("%s-%v", name, uuid.New().String()[0:8]) |
nothing calls this directly
no test coverage detected