MCPcopy
hub / github.com/cli/cli / FromURL

Function FromURL

internal/ghrepo/repo.go:61–72  ·  view source on GitHub ↗

FromURL extracts the GitHub repository information from a git remote URL

(u *url.URL)

Source from the content-addressed store, hash-verified

59
60// FromURL extracts the GitHub repository information from a git remote URL
61func FromURL(u *url.URL) (Interface, error) {
62 if u.Hostname() == "" {
63 return nil, fmt.Errorf("no hostname detected")
64 }
65
66 parts := strings.SplitN(strings.Trim(u.Path, "/"), "/", 3)
67 if len(parts) != 2 {
68 return nil, fmt.Errorf("invalid path: %s", u.Path)
69 }
70
71 return NewWithHost(parts[0], strings.TrimSuffix(parts[1], ".git"), u.Hostname()), nil
72}
73
74func normalizeHostname(h string) string {
75 return strings.ToLower(strings.TrimPrefix(h, "www."))

Callers 12

TranslateRemotesFunction · 0.92
linkedBranchRepoFromURLFunction · 0.92
cloneRunFunction · 0.92
forkRunFunction · 0.92
parseGitHubURLFunction · 0.92
resolveMethod · 0.92
OwnerMethod · 0.92
repoFromPathFunction · 0.92
NewCmdExtensionFunction · 0.92
getExtensionsFunction · 0.92
RepoNameFromRemoteFunction · 0.92
Test_repoFromURLFunction · 0.85

Calls 2

NewWithHostFunction · 0.85
ErrorfMethod · 0.65

Tested by 1

Test_repoFromURLFunction · 0.68