Skip to content

Commit

Permalink
Support parsing labels that begin '@@' (#1651)
Browse files Browse the repository at this point in the history
  • Loading branch information
mark-thm committed Oct 19, 2023
1 parent 545aa35 commit a957b83
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
4 changes: 4 additions & 0 deletions label/label.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,10 @@ func Parse(s string) (Label, error) {

relative := true
var repo string
// if target name begins @@ drop the first @
if strings.HasPrefix(s, "@@") {
s = s[len("@"):]
}
if strings.HasPrefix(s, "@") {
relative = false
endRepo := strings.Index(s, "//")
Expand Down
1 change: 1 addition & 0 deletions label/label_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ func TestParse(t *testing.T) {
{str: "@a//some/pkg/[someId]:[someId]", want: Label{Repo: "a", Pkg: "some/pkg/[someId]", Name: "[someId]"}},
{str: "@rules_python~0.0.0~pip~name_dep//:_pkg", want: Label{Repo: "rules_python~0.0.0~pip~name_dep", Name: "_pkg"}},
{str: "@rules_python~0.0.0~pip~name//:dep_pkg", want: Label{Repo: "rules_python~0.0.0~pip~name", Name: "dep_pkg"}},
{str: "@@rules_python~0.26.0~python~python_3_10_x86_64-unknown-linux-gnu//:python_runtimes", want: Label{Repo: "rules_python~0.26.0~python~python_3_10_x86_64-unknown-linux-gnu", Name: "python_runtimes"}},
} {
got, err := Parse(tc.str)
if err != nil && !tc.wantErr {
Expand Down

0 comments on commit a957b83

Please sign in to comment.