(owner, repo string)
| 3215 | } |
| 3216 | |
| 3217 | func githubRepoExists(owner, repo string) (bool, error) { |
| 3218 | if _, err := exec.LookPath("gh"); err != nil { |
| 3219 | return false, fmt.Errorf("gh CLI not found in PATH: %w", err) |
| 3220 | } |
| 3221 | |
| 3222 | fullName := fmt.Sprintf("%s/%s", owner, repo) |
| 3223 | cmd := exec.Command("gh", "repo", "view", fullName, "--json", "name") |
| 3224 | output, err := cmd.CombinedOutput() |
| 3225 | if err != nil { |
| 3226 | var exitErr *exec.ExitError |
| 3227 | if errors.As(err, &exitErr) && exitErr.ExitCode() == 1 { |
| 3228 | return false, nil |
| 3229 | } |
| 3230 | trimmed := strings.TrimSpace(string(output)) |
| 3231 | if trimmed != "" { |
| 3232 | return false, fmt.Errorf("gh repo view %s: %s", fullName, trimmed) |
| 3233 | } |
| 3234 | return false, fmt.Errorf("gh repo view %s: %w", fullName, err) |
| 3235 | } |
| 3236 | |
| 3237 | return true, nil |
| 3238 | } |
| 3239 | |
| 3240 | func createPrivateRepository(ctx *snap.Context, owner, repo string) error { |
| 3241 | repoFull := fmt.Sprintf("%s/%s", owner, repo) |
no outgoing calls
no test coverage detected