MCPcopy
hub / github.com/cli/cli / parseRemotes

Function parseRemotes

git/client.go:940–976  ·  view source on GitHub ↗
(remotesStr []string)

Source from the content-addressed store, hash-verified

938}
939
940func parseRemotes(remotesStr []string) RemoteSet {
941 remotes := RemoteSet{}
942 for _, r := range remotesStr {
943 match := remoteRE.FindStringSubmatch(r)
944 if match == nil {
945 continue
946 }
947 name := strings.TrimSpace(match[1])
948 urlStr := strings.TrimSpace(match[2])
949 urlType := strings.TrimSpace(match[3])
950
951 url, err := ParseURL(urlStr)
952 if err != nil {
953 continue
954 }
955
956 var rem *Remote
957 if len(remotes) > 0 {
958 rem = remotes[len(remotes)-1]
959 if name != rem.Name {
960 rem = nil
961 }
962 }
963 if rem == nil {
964 rem = &Remote{Name: name}
965 remotes = append(remotes, rem)
966 }
967
968 switch urlType {
969 case "fetch":
970 rem.FetchURL = url
971 case "push":
972 rem.PushURL = url
973 }
974 }
975 return remotes
976}
977
978func parseRemoteURLOrName(value string) (*url.URL, string) {
979 if strings.Contains(value, ":") {

Callers 2

TestParseRemotesFunction · 0.85
RemotesMethod · 0.85

Calls 1

ParseURLFunction · 0.70

Tested by 1

TestParseRemotesFunction · 0.68