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

Function pickBranchCandidateForRemote

cli/flow/main.go:4863–4879  ·  view source on GitHub ↗
(remote string, candidates []string)

Source from the content-addressed store, hash-verified

4861}
4862
4863func 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
4881func gitRemoteHasBranch(remote, branch string) (bool, error) {
4882 cmd := exec.Command("git", "ls-remote", "--heads", remote, branch)

Callers 1

runGitCheckoutFunction · 0.85

Calls 1

gitRemoteHasBranchFunction · 0.85

Tested by

no test coverage detected