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

Function parseRemotes

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

Source from the content-addressed store, hash-verified

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

Callers 2

TestParseRemotesFunction · 0.85
RemotesMethod · 0.85

Calls 1

ParseURLFunction · 0.70

Tested by 1

TestParseRemotesFunction · 0.68