From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: iceBear67 Date: Fri, 14 Aug 2026 04:47:50 +0000 Subject: [PATCH] Brand fork builds in --version output Adds FORK_NAME/fork_tag() to xai-grok-version and splices the tag into the pager's version line, so a locally built binary reads grok [newgrok] 1.0.3 (abc1234) and is never mistaken for an official xAI release. The tag is placed immediately after "grok " rather than appended, because main.rs's version_output_writer_preserves_channel_aware_contract test asserts the line still ends with the channel label (or ")"). [EXAMPLE PATCH] Demonstrates patching upstream Rust source. Safe to drop: delete the patch file and run 'make apply'. diff --git a/crates/codegen/xai-grok-pager-bin/src/main.rs b/crates/codegen/xai-grok-pager-bin/src/main.rs index ac1adc4fc7800e507742d4ae4bb7067edf2959f5..19238e835bb37d8d9670c70b0402d43caf248827 100644 --- a/crates/codegen/xai-grok-pager-bin/src/main.rs +++ b/crates/codegen/xai-grok-pager-bin/src/main.rs @@ -1788,7 +1788,8 @@ fn install_heap_profile_hooks() { } fn version_text(channel_label: &str) -> String { format!( - "grok {}\n", + "grok {} {}\n", + xai_grok_version::fork_tag(), xai_grok_version::display_version_with_commit(env!("VERSION_WITH_COMMIT"), channel_label,) ) } diff --git a/crates/codegen/xai-grok-version/src/lib.rs b/crates/codegen/xai-grok-version/src/lib.rs index 29fdfc1e64ea1df96f0ca3e1afe78c9ac37843bd..f56d96d34b828a0c10267fca407bc0b14e0c2a55 100644 --- a/crates/codegen/xai-grok-version/src/lib.rs +++ b/crates/codegen/xai-grok-version/src/lib.rs @@ -9,6 +9,15 @@ pub const VERSION: &str = match option_env!("GROK_VERSION") { None => env!("CARGO_PKG_VERSION"), }; +/// Name of this downstream fork. Builds from this tree are not official xAI +/// releases, so every user-facing version line carries the tag below. +pub const FORK_NAME: &str = "newgrok"; + +/// Bracketed fork marker for version output, e.g. `"[newgrok]"`. +pub fn fork_tag() -> String { + format!("[{FORK_NAME}]") +} + /// [`TEST_VERSION_ENV`] override first, then [`VERSION`]. Trimmed so /// non-semver-aware callers can pass the result straight into parsing. pub fn installed() -> String { @@ -72,4 +81,12 @@ mod tests { assert_eq!(display_version(""), VERSION); assert!(display_version(" [stable]").ends_with("[stable]")); } + + /// The fork marker must stay non-empty and bracketed -- the pager splices it + /// into `--version` output, whose format test asserts the surrounding shape. + #[test] + fn test_fork_tag_is_bracketed_fork_name() { + assert!(!FORK_NAME.is_empty()); + assert_eq!(fork_tag(), format!("[{FORK_NAME}]")); + } }