| 5087 | } |
| 5088 | |
| 5089 | func listGitRemotes() ([]string, error) { |
| 5090 | out, err := exec.Command("git", "remote").Output() |
| 5091 | if err != nil { |
| 5092 | return nil, fmt.Errorf("git remote: %w", err) |
| 5093 | } |
| 5094 | |
| 5095 | trimmed := strings.TrimSpace(string(out)) |
| 5096 | if trimmed == "" { |
| 5097 | return nil, fmt.Errorf("no git remotes configured") |
| 5098 | } |
| 5099 | |
| 5100 | lines := strings.Split(trimmed, "\n") |
| 5101 | remotes := make([]string, 0, len(lines)) |
| 5102 | for _, line := range lines { |
| 5103 | name := strings.TrimSpace(line) |
| 5104 | if name != "" { |
| 5105 | remotes = append(remotes, name) |
| 5106 | } |
| 5107 | } |
| 5108 | |
| 5109 | if len(remotes) == 0 { |
| 5110 | return nil, fmt.Errorf("no git remotes configured") |
| 5111 | } |
| 5112 | |
| 5113 | return remotes, nil |
| 5114 | } |
| 5115 | |
| 5116 | func selectGitRemote(remotes []string, preferred string) (string, error) { |
| 5117 | if len(remotes) == 0 { |