(ctx *snap.Context)
| 3251 | } |
| 3252 | |
| 3253 | func runCreateRepoFromRemote(ctx *snap.Context) error { |
| 3254 | if err := ensureGitRepository(); err != nil { |
| 3255 | return err |
| 3256 | } |
| 3257 | |
| 3258 | cmd := exec.Command("git", "remote", "get-url", "origin") |
| 3259 | output, err := cmd.Output() |
| 3260 | if err != nil { |
| 3261 | return fmt.Errorf("get git remote origin: %w", err) |
| 3262 | } |
| 3263 | |
| 3264 | remoteURL := strings.TrimSpace(string(output)) |
| 3265 | if remoteURL == "" { |
| 3266 | return fmt.Errorf("git remote origin is empty") |
| 3267 | } |
| 3268 | |
| 3269 | owner, repo, _, err := parseGitHubCloneInfo(remoteURL) |
| 3270 | if err != nil { |
| 3271 | return fmt.Errorf("parse remote URL %q: %w", remoteURL, err) |
| 3272 | } |
| 3273 | |
| 3274 | exists, err := githubRepoExists(owner, repo) |
| 3275 | if err != nil { |
| 3276 | return fmt.Errorf("check if repo exists: %w", err) |
| 3277 | } |
| 3278 | |
| 3279 | if exists { |
| 3280 | fmt.Fprintf(ctx.Stdout(), "Repository %s/%s already exists\n", owner, repo) |
| 3281 | return nil |
| 3282 | } |
| 3283 | |
| 3284 | if err := createPrivateRepository(ctx, owner, repo); err != nil { |
| 3285 | return err |
| 3286 | } |
| 3287 | |
| 3288 | fmt.Fprintf(ctx.Stdout(), "Created repository %s/%s\n", owner, repo) |
| 3289 | return nil |
| 3290 | } |
| 3291 | |
| 3292 | func runGitIgnore(ctx *snap.Context) error { |
| 3293 | if err := ensureGitRepository(); err != nil { |
no test coverage detected