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>
This commit is contained in:
Executable
+49
@@ -0,0 +1,49 @@
|
||||
#!/usr/bin/env bash
|
||||
# Export every commit in work/ above the `base` tag back into patches/.
|
||||
#
|
||||
# This is the CraftBukkit/Spigot `rebuildPatches.sh` step and the only way
|
||||
# changes leave work/. Run it after every commit you make in work/.
|
||||
|
||||
source "$(dirname "${BASH_SOURCE[0]}")/lib.sh"
|
||||
|
||||
assert_work_ready
|
||||
cd "$WORK_DIR"
|
||||
|
||||
if [[ -n "$(git status --porcelain)" ]]; then
|
||||
warn "work/ has uncommitted changes -- they will NOT be exported."
|
||||
warn "Commit them first: cd work && git add -A && git commit"
|
||||
fi
|
||||
|
||||
n="$(git rev-list --count "$BASE_TAG..HEAD")"
|
||||
info "Exporting $n commit(s) above $BASE_TAG -> patches/"
|
||||
|
||||
mkdir -p "$PATCHES_DIR"
|
||||
# Clear first: dropping or reordering commits in work/ must not leave orphaned
|
||||
# patch files behind, and format-patch only ever writes, never deletes.
|
||||
rm -f "$PATCHES_DIR"/*.patch
|
||||
|
||||
if [[ "$n" -eq 0 ]]; then
|
||||
info "No commits above $BASE_TAG -- patches/ is now empty."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# --zero-commit the "From <sha>" line would otherwise change on every single
|
||||
# rebase, producing a diff in every patch file for no reason
|
||||
# --full-index full blob hashes give `git am --3way` something to fall back
|
||||
# on when context has drifted
|
||||
# --no-signature drops the trailing "-- \n2.47.3" git version banner
|
||||
# --no-stat / -N match Spigot's output shape (no diffstat, no "[PATCH n/m]")
|
||||
git format-patch \
|
||||
--quiet \
|
||||
--no-stat \
|
||||
-N \
|
||||
--zero-commit \
|
||||
--full-index \
|
||||
--no-signature \
|
||||
--output-directory "$PATCHES_DIR" \
|
||||
"$BASE_TAG"
|
||||
|
||||
info "patches/ now holds $(count_patches) patch file(s):"
|
||||
for f in "$PATCHES_DIR"/*.patch; do
|
||||
printf ' %s\n' "$(basename "$f")"
|
||||
done
|
||||
Reference in New Issue
Block a user