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

Function parseRemotes

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

Source from the content-addressed store, hash-verified

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

Callers 2

TestParseRemotesFunction · 0.85
RemotesMethod · 0.85

Calls 1

ParseURLFunction · 0.70

Tested by 1

TestParseRemotesFunction · 0.68