Skip to content

Commit bf3c9fd

Browse files
authored
Merge pull request #1 from Wompipomp/gitlab
fix: gitlab sections and allow dot in usernames
2 parents 6c79014 + 169867e commit bf3c9fd

4 files changed

Lines changed: 16 additions & 6 deletions

File tree

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
11
/codeowners
2+
/.idea
3+
/co

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
.PHONY: build
22
build:
3-
go build ./cmd/codeowners
3+
go build -o co ./cmd/codeowners

parse.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ import (
1010
)
1111

1212
var (
13-
emailRegexp = regexp.MustCompile(`\A[A-Z0-9a-z\._%\+\-]+@[A-Za-z0-9\.\-]+\.[A-Za-z]{2,6}\z`)
14-
teamRegexp = regexp.MustCompile(`\A@([a-zA-Z0-9\-]+\/[a-zA-Z0-9_\-]+)\z`)
15-
usernameRegexp = regexp.MustCompile(`\A@([a-zA-Z0-9\-]+)\z`)
13+
emailRegexp = regexp.MustCompile(`\A[A-Z0-9a-z._%+\-]+@[A-Za-z0-9.\-]+\.[A-Za-z]{2,6}\z`)
14+
teamRegexp = regexp.MustCompile(`\A@([a-zA-Z0-9\-.]+/[a-zA-Z0-9_\-]+)\z`)
15+
usernameRegexp = regexp.MustCompile(`\A@([a-zA-Z0-9\-.]+)\z`)
1616
)
1717

1818
const (
@@ -29,8 +29,8 @@ func ParseFile(f io.Reader) (Ruleset, error) {
2929
lineNo++
3030
line := scanner.Text()
3131

32-
// Ignore blank lines and comments
33-
if len(line) == 0 || line[0] == '#' {
32+
// Ignore blank lines and comments and gitlab sections
33+
if len(line) == 0 || line[0] == '#' || line[0] == '[' {
3434
continue
3535
}
3636

parse_test.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,14 @@ func TestParseRule(t *testing.T) {
2222
Owners: []Owner{{Value: "user", Type: "username"}},
2323
},
2424
},
25+
{
26+
name: "username owners with . in the name",
27+
rule: "file.txt @user.foo",
28+
expected: Rule{
29+
pattern: mustBuildPattern(t, "file.txt"),
30+
Owners: []Owner{{Value: "user.foo", Type: "username"}},
31+
},
32+
},
2533
{
2634
name: "team owners",
2735
rule: "file.txt @org/team",

0 commit comments

Comments
 (0)