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

Function selectGitRemote

cli/flow/main.go:5116–5137  ·  view source on GitHub ↗
(remotes []string, preferred string)

Source from the content-addressed store, hash-verified

5114}
5115
5116func selectGitRemote(remotes []string, preferred string) (string, error) {
5117 if len(remotes) == 0 {
5118 return "", fmt.Errorf("no git remotes configured")
5119 }
5120
5121 if preferred != "" {
5122 for _, r := range remotes {
5123 if r == preferred {
5124 return preferred, nil
5125 }
5126 }
5127 return "", fmt.Errorf("git remote %q not found", preferred)
5128 }
5129
5130 for _, r := range remotes {
5131 if r == "origin" {
5132 return r, nil
5133 }
5134 }
5135
5136 return remotes[0], nil
5137}
5138
5139func gitRefExists(ref string) (bool, error) {
5140 cmd := exec.Command("git", "rev-parse", "--verify", "--quiet", ref)

Callers 1

runGitCheckoutFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected