Skip to content

Commit

Permalink
add git to pbo properties whenever present
Browse files Browse the repository at this point in the history
  • Loading branch information
BrettMayson committed Mar 26, 2023
1 parent 3caa03e commit c153946
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion bin/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>"]
Expand Down
18 changes: 16 additions & 2 deletions bin/src/modules/pbo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand All @@ -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(())
})
Expand All @@ -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();
Expand Down Expand Up @@ -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;
}

Expand Down

0 comments on commit c153946

Please sign in to comment.