Skip to content

Commit

Permalink
Support git https protocol (#46)
Browse files Browse the repository at this point in the history
  • Loading branch information
fmenezes authored Sep 2, 2020
1 parent 71cef28 commit 8a032c2
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
19 changes: 19 additions & 0 deletions checkers/access_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion checkers/github.go
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
4 changes: 4 additions & 0 deletions checkers/github_mock.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit 8a032c2

Please sign in to comment.