Commit a02e3837 authored by Scott Abbey's avatar Scott Abbey

Add basic prerelease handling

parent 02043558
......@@ -16,7 +16,10 @@ lazy_static! {
let minor = numeric_identifier;
let patch = numeric_identifier;
let regex = format!(r"^(?P<major>{})\.(?P<minor>{})\.(?P<patch>{})$", major, minor, patch);
let pre = r"\w+";
let regex = format!(r"^(?P<major>{})\.(?P<minor>{})\.(?P<patch>{})(:?-(?P<pre>{}))?$", major, minor, patch, pre);
println!("{}", regex);
let regex = Regex::new(&regex);
// this unwrap is okay because everything above here is const, so this will never fail.
......@@ -28,6 +31,7 @@ pub struct Version {
pub major: u64,
pub minor: u64,
pub patch: u64,
pub pre: Option<String>,
}
pub fn parse_version(version: &str) -> Result<Version, Box<Error>> {
......@@ -40,6 +44,7 @@ pub fn parse_version(version: &str) -> Result<Version, Box<Error>> {
major: captures.name("major").unwrap().parse().unwrap(),
minor: captures.name("minor").unwrap().parse().unwrap(),
patch: captures.name("patch").unwrap().parse().unwrap(),
pre: captures.name("pre").map(ToString::to_string)
})
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment