Skip to content

Commit

Permalink
Label's package may contain @s (#1249)
Browse files Browse the repository at this point in the history
See bazelbuild/bazel#15428 for context.

tl;dr: Bazel actually allows this, and some common rulesets (e.g.
`rules_nodejs`) rely heavily on it.
  • Loading branch information
illicitonion committed May 13, 2022
1 parent 1f6da0a commit 757e291
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion label/label.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ var NoLabel = Label{}

var (
labelRepoRegexp = regexp.MustCompile(`^@$|^[A-Za-z.-][A-Za-z0-9_.-]*$`)
labelPkgRegexp = regexp.MustCompile(`^[A-Za-z0-9/._-]*$`)
labelPkgRegexp = regexp.MustCompile(`^[A-Za-z0-9/._@-]*$`)
// This was taken from https://docs.bazel.build/versions/main/build-ref.html#name
// Note: We've manually removed space from the regex, because though these technically parse
// with Bazel (and can appear in query results), they cannot actually be used in practice.
Expand Down
1 change: 1 addition & 0 deletions label/label_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ func TestParse(t *testing.T) {
{str: "@a", want: Label{Repo: "a", Pkg: "", Name: "a"}},
{str: "@a//b", want: Label{Repo: "a", Pkg: "b", Name: "b"}},
{str: "@a//b:c", want: Label{Repo: "a", Pkg: "b", Name: "c"}},
{str: "@a//@b:c", want: Label{Repo: "a", Pkg: "@b", Name: "c"}},
{str: "@..//b:c", want: Label{Repo: "..", Pkg: "b", Name: "c"}},
{str: "@--//b:c", want: Label{Repo: "--", Pkg: "b", Name: "c"}},
{str: "//api_proto:api.gen.pb.go_checkshtest", want: Label{Pkg: "api_proto", Name: "api.gen.pb.go_checkshtest"}},
Expand Down

0 comments on commit 757e291

Please sign in to comment.