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)
| 416 | // '.git' extension from the URL before parsing it. |
| 417 | // Note that Github removes the '.git' extension from projects names at their creation |
| 418 | func 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 | |
| 433 | func getValidGithubRemoteURLs(repo repository.RepoCommon) ([]string, error) { |
| 434 | remotes, err := repo.GetRemotes() |
no outgoing calls