mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-10-14 19:26:56 -04:00
CI: cargo fmt xtask/src/version.rs (the fmt gate failed on main)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
604c20ed90
commit
5fab94753c
1 file changed
+3
-15
+3
-15
@@ -8,10 +8,7 @@ use std::path::Path;
|
||||
/// The `version = "…"` value inside `[workspace.package]`.
|
||||
pub fn read(manifest: &str) -> Result<String, String> {
|
||||
let (_, line) = find_line(manifest)?;
|
||||
let v = line
|
||||
.split_once('=')
|
||||
.map(|(_, v)| v.trim().trim_matches('"').to_string())
|
||||
.unwrap_or_default();
|
||||
let v = line.split_once('=').map(|(_, v)| v.trim().trim_matches('"').to_string()).unwrap_or_default();
|
||||
if v.is_empty() {
|
||||
return Err("empty [workspace.package] version".into());
|
||||
}
|
||||
@@ -48,20 +45,11 @@ pub fn validate(v: &str) -> Result<(), String> {
|
||||
None => (v, None),
|
||||
};
|
||||
let nums: Vec<&str> = core.split('.').collect();
|
||||
if nums.len() != 3
|
||||
|| nums.iter().any(|n| {
|
||||
n.is_empty()
|
||||
|| !n.bytes().all(|b| b.is_ascii_digit())
|
||||
|| (n.len() > 1 && n.starts_with('0'))
|
||||
})
|
||||
{
|
||||
if nums.len() != 3 || nums.iter().any(|n| n.is_empty() || !n.bytes().all(|b| b.is_ascii_digit()) || (n.len() > 1 && n.starts_with('0'))) {
|
||||
return bad();
|
||||
}
|
||||
if let Some(p) = pre
|
||||
&& (p.is_empty()
|
||||
|| p.split('.').any(|id| {
|
||||
id.is_empty() || !id.bytes().all(|b| b.is_ascii_alphanumeric() || b == b'-')
|
||||
}))
|
||||
&& (p.is_empty() || p.split('.').any(|id| id.is_empty() || !id.bytes().all(|b| b.is_ascii_alphanumeric() || b == b'-')))
|
||||
{
|
||||
return bad();
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user