//! Build-time version info exposed via the `build_info` module. //! //! `version_string` is `git describe --tags --always --dirty` output (or the //! `.version` field from `build.zig.zon` if git is unavailable at build time). //! `build_timestamp` is the committer timestamp of HEAD (Unix epoch //! seconds), or 0 when git is unavailable. Together they identify the //! binary precisely. //! //! The timestamp is deliberately per-commit rather than wall-clock: it //! keeps the build-options module cache-stable, so repeated `zig build` //! invocations don't relink the exe just because the second ticked over. //! //! Consumers (the `zfin version` command, snapshot metadata writers, bug //! reports) should route through this module rather than importing //! `build_info` directly, so the interface stays stable if we reshape the //! build options later. const std = @import("std"); const build_info = @import("build_info"); /// Version string, e.g. "v0.3.1", "v0.3.1-4-g1a2b3c4", "v0.3.1-dirty", /// "1a2b3c4" (no tags yet), or a fallback from build.zig.zon. pub const version_string: []const u8 = build_info.version; /// Unix epoch seconds — committer timestamp of HEAD at build time, or 0 /// when git is unavailable. Rendered as ISO date by the `zfin version /// --verbose` command; 0 renders as 1970-01-01 (clearly-fake sentinel). pub const build_timestamp: i64 = build_info.build_timestamp; /// True when `version_string` ends in `-dirty`, indicating the build was /// produced from a worktree with uncommitted changes. pub fn isDirty() bool { return std.mem.endsWith(u8, version_string, "-dirty"); } test "version_string is non-empty" { try std.testing.expect(version_string.len > 0); } test "build_timestamp is either zero (no-git fallback) or a plausible commit time" { // Two acceptable shapes: // 0 → git unavailable or `git log -1 %ct` failed // > 1_577_836_800 → real committer timestamp (Jan 1 2020 onward) // Anything in between would indicate a broken build-info wiring. try std.testing.expect(build_timestamp == 0 or build_timestamp > 1_577_836_800); }