Skip to content

Commit

Permalink
Fix use of @ in path names. (#15226)
Browse files Browse the repository at this point in the history
Fix use of `@` in path names as long as they are not followed by parameter syntax.

Fixes #15217.
  • Loading branch information
stuhood committed Apr 22, 2022
1 parent a858a62 commit 9eb71ad
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
7 changes: 4 additions & 3 deletions src/python/pants/build_graph/address_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ def assert_parsed(
assert_parsed(
"a#gen@k1=v1", generated_component="gen", path_component="a", parameters={"k1": "v1"}
)
assert_parsed("a@t", path_component="a@t")
assert_parsed("a@=", path_component="a@=")
assert_parsed("a@t,y", path_component="a@t,y")
assert_parsed("a@2.png:../t", path_component="a@2.png", target_component="../t")

# Absolute spec
assert_parsed("//a/b/c", path_component="a/b/c")
Expand Down Expand Up @@ -112,9 +116,6 @@ def test_address_input_parse_bad_path_component(spec: str) -> None:
@pytest.mark.parametrize(
"spec,expected",
[
("a@t", "one or more key=value pairs"),
("a@=", "one or more key=value pairs"),
("a@t,y", "one or more key=value pairs"),
("a@t=,y", "one or more key=value pairs"),
("a#", "non-empty generated target name"),
],
Expand Down
3 changes: 2 additions & 1 deletion src/rust/engine/address/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ pub struct SpecInput<'a> {

peg::parser! {
grammar parsers() for str {
rule path() -> &'input str = s:$([^':' | '@' | '#']*) { s }
rule path() -> &'input str =
s:$(([^':' | '@' | '#'] / ("@" !parameter()))*) { s }

rule target_name() -> &'input str
= quiet!{ s:$([^'#' | '@' | ':']+) { s } }
Expand Down

0 comments on commit 9eb71ad

Please sign in to comment.