fix #26 - improve regex for matching github repo. add unit test to cover

This commit is contained in:
Casey Lee
2019-02-12 23:09:51 -05:00
parent 7e92f699a9
commit af08b30ee5
2 changed files with 2 additions and 1 deletions
+1 -1
View File
@@ -137,7 +137,7 @@ func findGitSlug(url string) (string, string, error) {
codeCommitHTTPRegex := regexp.MustCompile(`^http(s?)://git-codecommit\.(.+)\.amazonaws.com/v1/repos/(.+)$`)
codeCommitSSHRegex := regexp.MustCompile(`ssh://git-codecommit\.(.+)\.amazonaws.com/v1/repos/(.+)$`)
httpRegex := regexp.MustCompile("^http(s?)://.*github.com.*/(.+)/(.+).git$")
sshRegex := regexp.MustCompile("github.com:(.+)/(.+).git$")
sshRegex := regexp.MustCompile("github.com[:/](.+)/(.+).git$")
if matches := codeCommitHTTPRegex.FindStringSubmatch(url); matches != nil {
return "CodeCommit", matches[3], nil
+1
View File
@@ -25,6 +25,7 @@ func TestFindGitSlug(t *testing.T) {
{"[email protected]:nektos/act.git", "GitHub", "nektos/act"},
{"https://github.com/nektos/act.git", "GitHub", "nektos/act"},
{"http://github.com/nektos/act.git", "GitHub", "nektos/act"},
{"git+ssh://[email protected]/owner/repo.git", "GitHub", "owner/repo"},
{"http://myotherrepo.com/act.git", "", "http://myotherrepo.com/act.git"},
}