MCPcopy Create free account
hub / github.com/cli/cli / parseRemotes

Function parseRemotes

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

Source from the content-addressed store, hash-verified

1001}
1002
1003func parseRemotes(remotesStr []string) RemoteSet {
1004 remotes := RemoteSet{}
1005 for _, r := range remotesStr {
1006 match := remoteRE.FindStringSubmatch(r)
1007 if match == nil {
1008 continue
1009 }
1010 name := strings.TrimSpace(match[1])
1011 urlStr := strings.TrimSpace(match[2])
1012 urlType := strings.TrimSpace(match[3])
1013
1014 url, err := ParseURL(urlStr)
1015 if err != nil {
1016 continue
1017 }
1018
1019 var rem *Remote
1020 if len(remotes) > 0 {
1021 rem = remotes[len(remotes)-1]
1022 if name != rem.Name {
1023 rem = nil
1024 }
1025 }
1026 if rem == nil {
1027 rem = &Remote{Name: name}
1028 remotes = append(remotes, rem)
1029 }
1030
1031 switch urlType {
1032 case "fetch":
1033 rem.FetchURL = url
1034 case "push":
1035 rem.PushURL = url
1036 }
1037 }
1038 return remotes
1039}
1040
1041func parseRemoteURLOrName(value string) (*url.URL, string) {
1042 if strings.Contains(value, ":") {

Callers 2

TestParseRemotesFunction · 0.85
RemotesMethod · 0.85

Calls 1

ParseURLFunction · 0.70

Tested by 1

TestParseRemotesFunction · 0.68