Skip to content

Commit 6699394

Browse files
authored
fix: Relaxing label parsing for Bazel 8 (#2021)
<!-- Thanks for sending a PR! Before submitting: 1. If this is your first PR, please read CONTRIBUTING.md and sign the CLA first. We cannot review code without a signed CLA. 2. Please file an issue *first*. All features and most bug fixes should have an associated issue with a design discussed and decided upon. Small bug fixes and documentation improvements don't need issues. 3. New features and bug fixes must have tests. Documentation may need to be updated. If you're unsure what to update, send the PR, and we'll discuss in review. --> **What type of PR is this?** > Uncomment one line below and remove others. > Bug fix **What package or component does this PR mostly affect?** > For example: > all **What does this PR do? Why is it needed?** The label format changed with Bazel 8 and needs to be adapted here **Which issues(s) does this PR fix?** Fixes #2019 **Other notes for review**
1 parent 1bbedea commit 6699394

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

label/label.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ var NoLabel = Label{}
7171
var (
7272
// This was taken from https://github.com/bazelbuild/bazel/blob/71fb1e4188b01e582a308cfe4bcbf1c730eded1b/src/main/java/com/google/devtools/build/lib/cmdline/RepositoryName.java#L159C1-L164
7373
// ~ and + are both allowed as the former is used in canonical repo names by Bazel 7 and earlier and the latter in Bazel 8.
74-
labelRepoRegexp = regexp.MustCompile(`^@$|^[A-Za-z0-9_.-][A-Za-z0-9_.~+-]*$`)
74+
labelRepoRegexp = regexp.MustCompile(`^@$|^[A-Za-z0-9_.~+-]*$`)
7575
// This was taken from https://github.com/bazelbuild/bazel/blob/master/src/main/java/com/google/devtools/build/lib/cmdline/LabelValidator.java
7676
// Package names may contain all 7-bit ASCII characters except:
7777
// 0-31 (control characters)

label/label_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ func TestParse(t *testing.T) {
9191
{str: "@rules_python++pip+name_dep//:_pkg", want: Label{Repo: "rules_python++pip+name_dep", Name: "_pkg"}},
9292
{str: "@rules_python++pip+name//:dep_pkg", want: Label{Repo: "rules_python++pip+name", Name: "dep_pkg"}},
9393
{str: "@@rules_python++python+python_3_10_x86_64-unknown-linux-gnu//:python_runtimes", want: Label{Repo: "rules_python++python+python_3_10_x86_64-unknown-linux-gnu", Name: "python_runtimes", Canonical: true}},
94+
{str: "@@+toolchains+jfrog_linux_amd64//:jfrog_toolchain", want: Label{Repo: "+toolchains+jfrog_linux_amd64", Name: "jfrog_toolchain", Canonical: true}},
9495
} {
9596
got, err := Parse(tc.str)
9697
if err != nil && !tc.wantErr {

0 commit comments

Comments
 (0)