Files
newgrok/patches/0001-Brand-fork-builds-in-version-output.patch
T
iceBear67andClaude Opus 5 618c8e31ee Set up CraftBukkit-style patch workflow for xai-org/grok-build
Upstream is a periodic one-way export of xAI's monorepo (linear
"Synced from monorepo" commits, SOURCE_REV pinning the internal SHA)
and explicitly refuses external contributions. So local changes can
never be upstreamed, and upstream re-drops the whole tree on every
sync -- structurally the same problem CraftBukkit has with Mojang.

Adopt the Spigot/BuildTools model: patches/ is the source of truth,
work/ is a disposable build artifact regenerated from upstream.rev
plus patches/.

  scripts/apply-patches.sh    ~ applyPatches.sh
  scripts/rebuild-patches.sh  ~ rebuildPatches.sh
  scripts/update-upstream.sh  forward-ports patches onto a new sync
  scripts/setup.sh            toolchain: rust 1.94.0, dotslash/protoc
  upstream.rev                ~ BuildTools versions/*.json pin

format-patch uses --zero-commit so rebases do not rewrite the From
line of every patch, and apply's git clean preserves work/target so
replaying patches does not cost a cold Rust rebuild.

Ships two [EXAMPLE PATCH] commits demonstrating a source edit and a
new-file addition; both are safe to delete.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-14 04:50:07 +00:00

67 lines
2.7 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: iceBear67 <icebear67@sfclub.cc>
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}]"));
+ }
}