1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
// Copyright (c) 2026, Salesforce, Inc. All rights reserved.
// SPDX-License-Identifier: Apache-2.0 OR MIT
//! Build-time capture of the current git commit hash.
//!
//! Runs `git rev-parse --short=8 HEAD` and exposes the result as the
//! `HYPERDB_GIT_HASH` compile-time env var, consumed via `env!` in
//! `src/version.rs`. Also detects whether the working tree has
//! uncommitted changes and, when so, appends both a `-dirty` marker
//! **and** an ISO 8601 basic UTC build timestamp (e.g.
//! `-20260423T184900Z`) so two iterative builds of the same dirty
//! tree can still be told apart — the hash alone stops being unique
//! the moment uncommitted edits enter the picture.
//!
//! The timestamp shape is deliberate:
//!
//! * Real ISO 8601 basic format (no colons or dashes inside the
//! datetime), which is safe in filenames, URLs, and version
//! identifiers everywhere we might carry it (logs, status output,
//! bug reports).
//! * `T` separator and `Z` suffix make it unambiguously UTC and
//! obviously a timestamp — not another commit hash.
//! * Sortable lexicographically, so later rebuilds naturally sort
//! after earlier ones even when only the timestamp differs.
//!
//! Clean builds are left alone: the commit hash already uniquely
//! identifies them, so no timestamp is appended.
//!
//! Falls back to `unknown` on any failure (no git binary, not a repo,
//! detached state, etc.) so the crate still builds for consumers who
//! obtained the source as a tarball.
//!
//! `Cargo.lock` is excluded from the dirty check via a git pathspec —
//! see the inline comment by the `git status` invocation for why.
use Command;