Skip to content

Commit

Permalink
Fix use of @ in path names. (pantsbuild#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 pantsbuild#15217.

[ci skip-build-wheels]
  • Loading branch information
stuhood committed Apr 22, 2022
1 parent fc38f32 commit 4f7d0aa
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
9 changes: 4 additions & 5 deletions src/python/pants/build_graph/address_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ def assert_parsed(
# Parameters
assert_parsed("a@k=v", path_component="a", parameters={"k": "v"})
assert_parsed("a@k1=v1,k2=v2", path_component="a", parameters={"k1": "v1", "k2": "v2"})
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 @@ -107,11 +111,6 @@ def test_address_input_parse_bad_path_component(spec: str) -> None:
"spec,expected",
[
("a:", "non-empty target name"),
("a@t", "one or more key=value pairs"),
("a@=", "one or more key=value pairs"),
("a@t=", "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 @@ -34,7 +34,8 @@ pub struct AddressInput<'a> {

peg::parser! {
grammar relative_address_parser() 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 4f7d0aa

Please sign in to comment.