diff --git a/build.rs b/build.rs index fdc9b74..9407ff7 100644 --- a/build.rs +++ b/build.rs @@ -12,17 +12,5 @@ fn main() { } fn get_git_version() -> Result> { - 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)?) } diff --git a/contrib/git-version.sh b/contrib/git-version.sh new file mode 100755 index 0000000..15131d2 --- /dev/null +++ b/contrib/git-version.sh @@ -0,0 +1,3 @@ +#!/bin/sh + +git describe --long | sed 's/-/.r/;s/-/./'