diff --git a/checkers/access_test.go b/checkers/access_test.go index d4b45a2..bd8e27f 100644 --- a/checkers/access_test.go +++ b/checkers/access_test.go @@ -138,6 +138,25 @@ func TestAccessCheckPassNoOwners(t *testing.T) { } } +func TestAccessCheckPassHttpGitConfig(t *testing.T) { + input := struct { + lineNo int + line string + }{ + lineNo: 1, + line: "filepattern @ownerWithAccess", + } + checker := checkers.Access{} + validator := checker.NewValidator(codeowners.ValidatorOptions{ + Directory: "http", + CodeownersFileLocation: "CODEOWNERS", + GithubToken: "token", + }) + got := validator.ValidateLine(input.lineNo, input.line) + if got != nil { + t.Errorf("Input: %v, Want: %v, Got: %v", input, nil, got) + } +} func TestAccessCheckNoTokenPass(t *testing.T) { input := struct { lineNo int diff --git a/checkers/github.go b/checkers/github.go index 33a8a84..f9d1167 100644 --- a/checkers/github.go +++ b/checkers/github.go @@ -24,7 +24,7 @@ type accessAPI struct { } func (a *accessAPI) extractRepoData() { - r := regexp.MustCompile(`github.com[\:\/]([A-Za-z0-9-]+)\/([A-Za-z0-9-]+)\.git`) + r := regexp.MustCompile(`github\.com[\:\/]([A-Za-z0-9-]+)\/([A-Za-z0-9-]+)(?:\.git)?$`) data := r.FindStringSubmatch(a.repoURL) a.repoOwner = data[1] a.repoName = data[2] diff --git a/checkers/github_mock.go b/checkers/github_mock.go index 227eb3c..82279d3 100644 --- a/checkers/github_mock.go +++ b/checkers/github_mock.go @@ -18,6 +18,10 @@ func (a *accessAPI) extractRepoURL() error { if a.directory == "bad" { return errors.New("Mocked error") } + if a.directory == "http" { + a.repoURL = "http://github.com/owner/repo" + return nil + } a.repoURL = "git@github.com:owner/repo.git" return nil }