From af08b30ee56e834e17e759383710a8ed0a5b5b69 Mon Sep 17 00:00:00 2001 From: Casey Lee Date: Tue, 12 Feb 2019 23:08:07 -0500 Subject: [PATCH] fix #26 - improve regex for matching github repo. add unit test to cover --- common/git.go | 2 +- common/git_test.go | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/common/git.go b/common/git.go index ed16854..edcd105 100644 --- a/common/git.go +++ b/common/git.go @@ -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 diff --git a/common/git_test.go b/common/git_test.go index e5f4e9e..f1312d1 100644 --- a/common/git_test.go +++ b/common/git_test.go @@ -25,6 +25,7 @@ func TestFindGitSlug(t *testing.T) { {"git@github.com: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://git@github.com/owner/repo.git", "GitHub", "owner/repo"}, {"http://myotherrepo.com/act.git", "", "http://myotherrepo.com/act.git"}, }