MCPcopy Index your code
hub / github.com/git-bug/git-bug / splitURL

Function splitURL

bridge/github/config.go:418–431  ·  view source on GitHub ↗

splitURL extract the owner and project from a github repository URL. It will remove the '.git' extension from the URL before parsing it. Note that Github removes the '.git' extension from projects names at their creation

(url string)

Source from the content-addressed store, hash-verified

416// '.git' extension from the URL before parsing it.
417// Note that Github removes the '.git' extension from projects names at their creation
418func splitURL(url string) (owner string, project string, err error) {
419 cleanURL := strings.TrimSuffix(url, ".git")
420
421 re := regexp.MustCompile(`github\.com[/:]([a-zA-Z0-9\-_]+)/([a-zA-Z0-9\-_.]+)`)
422
423 res := re.FindStringSubmatch(cleanURL)
424 if res == nil {
425 return "", "", ErrBadProjectURL
426 }
427
428 owner = res[1]
429 project = res[2]
430 return
431}
432
433func getValidGithubRemoteURLs(repo repository.RepoCommon) ([]string, error) {
434 remotes, err := repo.GetRemotes()

Callers 5

TestSplitURLFunction · 0.70
exportBugMethod · 0.70
ConfigureMethod · 0.70
promptURLFunction · 0.70
getValidGithubRemoteURLsFunction · 0.70

Calls

no outgoing calls

Tested by 1

TestSplitURLFunction · 0.56