diff --git a/Cargo.lock b/Cargo.lock index abccbe1e..3b2f7c27 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -721,7 +721,7 @@ checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" [[package]] name = "hemtt" -version = "1.2.0" +version = "1.3.0" dependencies = [ "ansi_term", "anyhow", diff --git a/bin/Cargo.toml b/bin/Cargo.toml index 7dae3797..d635c3f9 100644 --- a/bin/Cargo.toml +++ b/bin/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "hemtt" description = "HEMTT - Arma 3 Build Tool" -version = "1.2.0" +version = "1.3.0" edition = "2021" license = "GPL-2.0" authors = ["Brett Mayson "] diff --git a/bin/src/modules/pbo.rs b/bin/src/modules/pbo.rs index b302086f..e133a36a 100644 --- a/bin/src/modules/pbo.rs +++ b/bin/src/modules/pbo.rs @@ -3,6 +3,7 @@ use std::{ sync::atomic::{AtomicI16, Ordering}, }; +use git2::Repository; use hemtt_pbo::{prefix::FILES, Prefix, WritablePbo}; use hemtt_version::Version; use rayon::prelude::{IntoParallelRefIterator, ParallelIterator}; @@ -25,12 +26,21 @@ pub enum Collapse { pub fn build(ctx: &Context, collapse: Collapse) -> Result<(), Error> { let version = ctx.config().version().get()?; + let git_hash = { + if let Ok(repo) = Repository::open(".") { + let rev = repo.revparse_single("HEAD")?; + let id = rev.id().to_string(); + Some(id) + } else { + None + } + }; let counter = AtomicI16::new(0); ctx.addons() .to_vec() .par_iter() .map(|addon| { - _build(ctx, addon, collapse, &version)?; + _build(ctx, addon, collapse, &version, git_hash.as_ref())?; counter.fetch_add(1, Ordering::Relaxed); Ok(()) }) @@ -44,6 +54,7 @@ fn _build( addon: &Addon, collapse: Collapse, version: &Version, + git_hash: Option<&String>, ) -> Result<(), Error> { let mut pbo = WritablePbo::new(); let target = ctx.out_folder(); @@ -117,7 +128,10 @@ fn _build( ctx.config().hemtt().pbo_prefix_allow_leading_slash(), )?; pbo.add_property("prefix", prefix.into_inner()); - pbo.add_property("version", ctx.config().version().get()?.to_string()); + pbo.add_property("version", version.to_string()); + if let Some(hash) = git_hash { + pbo.add_property("git", hash); + } continue; }