Build identity in oxy --version e293c90dca62
oxy --version and oxy version --json (a new "build" field) name what was
built: OXY_BUILD, which make install sets from oxy describe, the heads of
a Flow build, or "local build". oxy_core::VERSION says the library's
version for hosts built on it.
closes #31
Author Andy McCall @andymccall <[email protected] >
When 1 month ago · 2026-09-29 17:43 UTC
Signature ✔ signed by Andy McCall
Hash e293c90dca62f8a298d5e58ec81c0573ee71083b2e18d499c6405730472fa678
Depends on 5b9c6ad45f6e 75167672ebcd fce44ae9ad29 ff0af1ee299d
Depended on by 141b1fb2ebe9 d443639bcf35
In bookmarks agents-in-readme bare-hashes carried-not-removed carry-identical doctor-trust identical-sides keyless-tags main merge-remote-bookmark only-help-103 paths-for-resolutions-and-amend push-notes show-stat subrepo-pin-state switch-says
In tags v0.1.0 v0.10.0 v0.11.0 v0.2.0 v0.3.0 v0.3.1 v0.4.0 v0.4.1 v0.4.2 v0.4.3 v0.4.4 v0.4.5 v0.4.6 v0.5.0 v0.5.1 v0.6.0 v0.7.0 v0.8.0 v0.9.0
Edits 8 atoms, 2 tree operations, 5 files
Browse the tree at this change
Makefile build.rs crates/oxy-core/src/lib.rs src/cli/mod.rs src/cli/workspace.rs
added
Makefile
+6 −0
1
+
# Build and install oxy with its build identity (oxy describe) in --version.
2
+
.PHONY: install
3
+
install:
4
+
OXY_BUILD="$$(oxy --plain describe 2>/dev/null)" CARGO_INCREMENTAL=0 cargo build --release
5
+
ln -sf $(CURDIR)/target/release/oxy $(HOME)/.local/bin/oxy
6
+
$(HOME)/.local/bin/oxy --version
added
build.rs
+27 −0
1
+
//! The build's identity, for `oxy --version`: `OXY_BUILD` when a release or
2
+
//! an install sets it (from `oxy describe`), else the heads a Flow job is
3
+
//! building, else "local build".
4
+
fn main() {
5
+
println!("cargo:rerun-if-env-changed=OXY_BUILD");
6
+
println!("cargo:rerun-if-env-changed=FLOW_HEADS");
7
+
let build = std::env::var("OXY_BUILD")
8
+
.ok()
9
+
.map(|b| b.trim().to_string())
10
+
.filter(|b| !b.is_empty())
11
+
.or_else(|| {
12
+
std::env::var("FLOW_HEADS")
13
+
.ok()
14
+
.and_then(|h| {
15
+
h.split('+')
16
+
.next()
17
+
.map(|x| format!("flow #{}", &x[..12.min(x.len())]))
18
+
})
19
+
.filter(|b| b.len() > "flow #".len())
20
+
})
21
+
.unwrap_or_else(|| "local build".into());
22
+
println!("cargo:rustc-env=OXY_BUILD_ID={build}");
23
+
println!(
24
+
"cargo:rustc-env=OXY_VERSION_LONG={} ({build})",
25
+
std::env::var("CARGO_PKG_VERSION").unwrap()
26
+
);
27
+
}
modified
crates/oxy-core/src/lib.rs
+3 −0
…
1 unchanged lines
2
2
//!
3
3
//! See `docs/spec.md` for the specification this implements.
4
4
5
+
/// This library's version, for hosts that report what they are built on.
6
+
pub const VERSION: &str = env!("CARGO_PKG_VERSION");
7
+
5
8
pub mod attest;
6
9
pub mod attributes;
7
10
pub mod cbor;
…
16 unchanged lines
modified
src/cli/mod.rs
+1 −1
…
14 unchanged lines
15
15
#[derive(Parser)]
16
16
#[command(
17
17
name = "oxy",
18
-
version,
18
+
version = env!("OXY_VERSION_LONG"),
19
19
about = "Oxygen: breathing fresh air into version control"
20
20
)]
21
21
struct Cli {
…
746 unchanged lines
modified
src/cli/workspace.rs
+4 −1
…
696 unchanged lines
697
697
"{}",
698
698
json::obj([
699
699
("version", json::s(env!("CARGO_PKG_VERSION"))),
700
+
// What was built: a release's or install's `oxy describe`,
701
+
// a Flow build's heads, or "local build".
702
+
("build", json::s(env!("OXY_BUILD_ID"))),
700
703
("protocol", json::n(oxy_core::protocol::PROTOCOL_VERSION)),
701
704
("format", json::n(2))
702
705
])
…
1 unchanged lines
704
707
} else {
705
708
println!(
706
709
"oxy {} (repository format 2, protocol {})",
707
-
env!("CARGO_PKG_VERSION "),
710
+
env!("OXY_VERSION_LONG "),
708
711
oxy_core::protocol::PROTOCOL_VERSION
709
712
);
710
713
}
…
851 unchanged lines