parseGithubRemote parses string remoteURL against known patterns matching GitHub remotes and returns the owner and repo, along with a boolean ok indicating whether a match was found. Possible GitHub remote formats (HTTPS/SSH): https://github.com/mroth/bump.git git@github.com:mroth/bump.git
(remoteURL string)
| 77 | // https://github.com/mroth/bump.git |
| 78 | // git@github.com:mroth/bump.git |
| 79 | func parseGithubRemote(remoteURL string) (owner, repo string, ok bool) { |
| 80 | re := regexp.MustCompile(`^(?:https://|git@)github.com[:/](.*)/(.*?)(?:\.git$|$)`) |
| 81 | matches := re.FindStringSubmatch(remoteURL) |
| 82 | if len(matches) < 3 { |
| 83 | return |
| 84 | } |
| 85 | return matches[1], matches[2], true |
| 86 | } |
no outgoing calls
searching dependent graphs…