You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
26 lines
891 B
26 lines
891 B
use std::process::Command;
|
|
fn main() {
|
|
let output = Command::new("git")
|
|
.arg("for-each-ref")
|
|
.arg("refs/remotes/origin")
|
|
.arg("--format")
|
|
.arg("%(refname)")
|
|
.output()
|
|
.unwrap();
|
|
assert!(output.status.success());
|
|
let mut releases = std::str::from_utf8(&output.stdout)
|
|
.unwrap()
|
|
.lines()
|
|
.filter_map(|l| l.strip_prefix("refs/remotes/origin/release-"))
|
|
.filter_map(|l| {
|
|
let mut parts = l.split('.');
|
|
let major = parts.next()?.parse::<u32>().ok()?;
|
|
let minor = parts.next()?.parse::<u32>().ok()?;
|
|
let patch = parts.next()?.parse::<u32>().ok()?;
|
|
Some((major, minor, patch))
|
|
})
|
|
.collect::<Vec<_>>();
|
|
releases.sort();
|
|
let (major, minor, patch) = releases.last().unwrap();
|
|
println!("{}.{}.{}", major, minor, patch);
|
|
}
|
|
|