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**
diff --git a/label/label.go b/label/label.go
index faf431c..2d4dd39 100644
--- a/label/label.go
+++ b/label/label.go
@@ -71,7 +71,7 @@
var (
// This was taken from https://github.com/bazelbuild/bazel/blob/71fb1e4188b01e582a308cfe4bcbf1c730eded1b/src/main/java/com/google/devtools/build/lib/cmdline/RepositoryName.java#L159C1-L164
// ~ and + are both allowed as the former is used in canonical repo names by Bazel 7 and earlier and the latter in Bazel 8.
- labelRepoRegexp = regexp.MustCompile(`^@$|^[A-Za-z0-9_.-][A-Za-z0-9_.~+-]*$`)
+ labelRepoRegexp = regexp.MustCompile(`^@$|^[A-Za-z0-9_.~+-]*$`)
// This was taken from https://github.com/bazelbuild/bazel/blob/master/src/main/java/com/google/devtools/build/lib/cmdline/LabelValidator.java
// Package names may contain all 7-bit ASCII characters except:
// 0-31 (control characters)
diff --git a/label/label_test.go b/label/label_test.go
index 083add8..8e9e7a1 100644
--- a/label/label_test.go
+++ b/label/label_test.go
@@ -91,6 +91,7 @@
{str: "@rules_python++pip+name_dep//:_pkg", want: Label{Repo: "rules_python++pip+name_dep", Name: "_pkg"}},
{str: "@rules_python++pip+name//:dep_pkg", want: Label{Repo: "rules_python++pip+name", Name: "dep_pkg"}},
{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}},
+ {str: "@@+toolchains+jfrog_linux_amd64//:jfrog_toolchain", want: Label{Repo: "+toolchains+jfrog_linux_amd64", Name: "jfrog_toolchain", Canonical: true}},
} {
got, err := Parse(tc.str)
if err != nil && !tc.wantErr {