Align version strings between AUR git package and the program itself. [skip ci]

This commit is contained in:
Antoine POPINEAU 2022-01-24 08:26:46 +01:00
parent 77be52aa65
commit e7872bb58f
No known key found for this signature in database
GPG Key ID: A78AC64694F84063
2 changed files with 4 additions and 13 deletions

View File

@ -12,17 +12,5 @@ fn main() {
}
fn get_git_version() -> Result<String, Box<dyn Error>> {
let tag = Command::new("git").args(&["describe", "--abbrev=0"]).output()?;
let tag = match tag.status.code() {
Some(0) => String::from_utf8(tag.stdout)?,
_ => "0.0.0".to_string(),
};
let count = String::from_utf8(Command::new("git").args(&["rev-list", "--count", "HEAD"]).output()?.stdout)?;
let commit = String::from_utf8(Command::new("git").args(&["rev-parse", "--short", "HEAD"]).output()?.stdout)?;
let version = format!("{}.r{}.{}", tag.trim(), count.trim(), commit.trim());
match version.as_str() {
"0.0.0.r." => Err("could not retrieve version".into()),
version => Ok(version.to_string()),
}
Ok(String::from_utf8(Command::new("./contrib/git-version.sh").output()?.stdout)?)
}

3
contrib/git-version.sh Executable file
View File

@ -0,0 +1,3 @@
#!/bin/sh
git describe --long | sed 's/-/.r/;s/-/./'