(remote string, candidates []string)
| 4861 | } |
| 4862 | |
| 4863 | func pickBranchCandidateForRemote(remote string, candidates []string) (string, error) { |
| 4864 | if len(candidates) == 0 { |
| 4865 | return "", fmt.Errorf("no branch candidates supplied") |
| 4866 | } |
| 4867 | |
| 4868 | for _, candidate := range candidates { |
| 4869 | hasBranch, err := gitRemoteHasBranch(remote, candidate) |
| 4870 | if err != nil { |
| 4871 | return "", err |
| 4872 | } |
| 4873 | if hasBranch { |
| 4874 | return candidate, nil |
| 4875 | } |
| 4876 | } |
| 4877 | |
| 4878 | return candidates[0], nil |
| 4879 | } |
| 4880 | |
| 4881 | func gitRemoteHasBranch(remote, branch string) (bool, error) { |
| 4882 | cmd := exec.Command("git", "ls-remote", "--heads", remote, branch) |
no test coverage detected