Skip to content

Commit 8a032c2

Browse files
authored
Support git https protocol (#46)
1 parent 71cef28 commit 8a032c2

3 files changed

Lines changed: 24 additions & 1 deletion

File tree

checkers/access_test.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,25 @@ func TestAccessCheckPassNoOwners(t *testing.T) {
138138
}
139139
}
140140

141+
func TestAccessCheckPassHttpGitConfig(t *testing.T) {
142+
input := struct {
143+
lineNo int
144+
line string
145+
}{
146+
lineNo: 1,
147+
line: "filepattern @ownerWithAccess",
148+
}
149+
checker := checkers.Access{}
150+
validator := checker.NewValidator(codeowners.ValidatorOptions{
151+
Directory: "http",
152+
CodeownersFileLocation: "CODEOWNERS",
153+
GithubToken: "token",
154+
})
155+
got := validator.ValidateLine(input.lineNo, input.line)
156+
if got != nil {
157+
t.Errorf("Input: %v, Want: %v, Got: %v", input, nil, got)
158+
}
159+
}
141160
func TestAccessCheckNoTokenPass(t *testing.T) {
142161
input := struct {
143162
lineNo int

checkers/github.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ type accessAPI struct {
2424
}
2525

2626
func (a *accessAPI) extractRepoData() {
27-
r := regexp.MustCompile(`github.com[\:\/]([A-Za-z0-9-]+)\/([A-Za-z0-9-]+)\.git`)
27+
r := regexp.MustCompile(`github\.com[\:\/]([A-Za-z0-9-]+)\/([A-Za-z0-9-]+)(?:\.git)?$`)
2828
data := r.FindStringSubmatch(a.repoURL)
2929
a.repoOwner = data[1]
3030
a.repoName = data[2]

checkers/github_mock.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ func (a *accessAPI) extractRepoURL() error {
1818
if a.directory == "bad" {
1919
return errors.New("Mocked error")
2020
}
21+
if a.directory == "http" {
22+
a.repoURL = "http://github.com/owner/repo"
23+
return nil
24+
}
2125
a.repoURL = "git@github.com:owner/repo.git"
2226
return nil
2327
}

0 commit comments

Comments
 (0)