MCPcopy Index your code
hub / github.com/nikivdev/go / githubRepoExists

Function githubRepoExists

cli/flow/main.go:3217–3238  ·  view source on GitHub ↗
(owner, repo string)

Source from the content-addressed store, hash-verified

3215}
3216
3217func 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
3240func createPrivateRepository(ctx *snap.Context, owner, repo string) error {
3241 repoFull := fmt.Sprintf("%s/%s", owner, repo)

Callers 1

runCreateRepoFromRemoteFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected