Skip to content

Commit 87d6b6c

Browse files
authored
Update //util/label to support + in packages (#1654)
* Update `//util/label` to support `+` in packages * And plus
1 parent ab6959d commit 87d6b6c

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

util/label/label.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,11 +148,12 @@ fn consume_package_name<'s>(input: &'s str, label: &'s str) -> Result<(&'s str,
148148
|| c == '('
149149
|| c == ')'
150150
|| c == '_'
151+
|| c == '+'
151152
}) {
152153
return Err(LabelError(err(
153154
label,
154155
"package names may contain only A-Z, \
155-
a-z, 0-9, '/', '-', '.', ' ', '$', '(', ')' and '_'.",
156+
a-z, 0-9, '/', '-', '.', ' ', '$', '(', ')', '_', and '+'.",
156157
)));
157158
}
158159
if package_name.ends_with('/') {
@@ -338,7 +339,7 @@ mod tests {
338339
analyze("//bar#:baz"),
339340
Err(LabelError(
340341
"//bar#:baz must be a legal label; package names may contain only A-Z, \
341-
a-z, 0-9, '/', '-', '.', ' ', '$', '(', ')' and '_'."
342+
a-z, 0-9, '/', '-', '.', ' ', '$', '(', ')', '_', and '+'."
342343
.to_string()
343344
))
344345
);
@@ -421,6 +422,12 @@ mod tests {
421422
vec!["foo", "bar"]
422423
);
423424

425+
// Plus (+) is valid in packages
426+
assert_eq!(
427+
analyze("@repo//foo/bar+baz:qaz")?.packages(),
428+
vec!["foo", "bar+baz"]
429+
);
430+
424431
Ok(())
425432
}
426433
}

0 commit comments

Comments
 (0)