//! Embed the release source commit when the build supplies it. //! //! The release pipeline builds the archive from one commit and records the //! same commit in `SOURCE_SHA`/`RELEASE_INFO.json`; embedding it here lets //! `marqdo inspect --environment --json` report the exact product identity //! without reading files next to the binary (marqdo-cli#26 ยง9.2). An ordinary //! development build simply has no embedded commit and reports `null` instead //! of guessing. fn main() { println!("cargo:rerun-if-env-changed=MARQDO_BUILD_SOURCE_SHA"); let Ok(sha) = std::env::var("MARQDO_BUILD_SOURCE_SHA") else { return; }; let sha = sha.trim(); let valid = sha.len() == 40 && sha .chars() .all(|ch| ch.is_ascii_hexdigit() && !ch.is_ascii_uppercase()); if valid { println!("cargo:rustc-env=MARQDO_BUILD_SOURCE_SHA={sha}"); } else { println!( "cargo:warning=MARQDO_BUILD_SOURCE_SHA is not a full lowercase 40-hex commit; \ the environment report will not claim a source commit" ); } }