in util/label/label.rs [66:103]
fn consume_repository_name<'s>(
input: &'s str,
label: &'s str,
) -> Result<(&'s str, Option<&'s str>)> {
if !input.starts_with('@') {
return Ok((input, None));
}
let slash_pos = input
.find("//")
.ok_or_else(|| err(label, "labels with repository must contain //."))?;
let repository_name = &input[1..slash_pos];
if repository_name.is_empty() {
return Ok((&input[1..], None));
}
if !repository_name
.chars()
.next()
.unwrap()
.is_ascii_alphabetic()
{
return Err(LabelError(err(
label,
"workspace names must start with a letter.",
)));
}
if !repository_name
.chars()
.all(|c| c.is_ascii_alphanumeric() || c == '-' || c == '_' || c == '.')
{
return Err(LabelError(err(
label,
"workspace names \
may contain only A-Z, a-z, 0-9, '-', '_', and '.'.",
)));
}
Ok((&input[slash_pos..], Some(repository_name)))
}