82 lines
2.6 KiB
Bash
Executable File
82 lines
2.6 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
|
cd "$ROOT"
|
|
|
|
UI_REVIEWED=0
|
|
ROOT_REVIEWED=0
|
|
SKIP_BUILD=0
|
|
for arg in "$@"; do
|
|
case "$arg" in
|
|
--ui-reviewed) UI_REVIEWED=1 ;;
|
|
--root-reviewed) ROOT_REVIEWED=1 ;;
|
|
--skip-build) SKIP_BUILD=1 ;;
|
|
*) echo "usage: $0 [--ui-reviewed] [--root-reviewed] [--skip-build]" >&2; exit 2 ;;
|
|
esac
|
|
done
|
|
|
|
if ! git rev-parse --is-inside-work-tree >/dev/null 2>&1; then
|
|
echo "error: not a Git checkout" >&2
|
|
exit 1
|
|
fi
|
|
PENDING_FILE="$(git rev-parse --git-path rustbox-upstream-pending)"
|
|
if [ ! -f "$PENDING_FILE" ]; then
|
|
echo "error: no pending Oxi sync; run ./scripts/sync-upstream.sh first" >&2
|
|
exit 1
|
|
fi
|
|
|
|
BASE="$(sed -n 's/^base=//p' "$PENDING_FILE")"
|
|
TARGET_SHA="$(sed -n 's/^target=//p' "$PENDING_FILE")"
|
|
BRANCH="$(sed -n 's/^branch=//p' "$PENDING_FILE")"
|
|
CURRENT_BRANCH="$(git branch --show-current)"
|
|
|
|
if [ -z "$BASE" ] || [ -z "$TARGET_SHA" ] || [ -z "$BRANCH" ]; then
|
|
echo "error: invalid pending sync metadata" >&2
|
|
exit 1
|
|
fi
|
|
if [ "$CURRENT_BRANCH" != "$BRANCH" ]; then
|
|
echo "error: pending Oxi sync belongs to branch '$BRANCH'; current branch is '$CURRENT_BRANCH'" >&2
|
|
exit 1
|
|
fi
|
|
if git diff --name-only --diff-filter=U | grep -q .; then
|
|
echo "error: unresolved merge conflicts remain" >&2
|
|
git diff --name-only --diff-filter=U >&2
|
|
exit 1
|
|
fi
|
|
if find . -path ./.git -prune -o -type f \( -name '*.ts' -o -name '*.tsx' \) -print -quit | grep -q .; then
|
|
echo "error: TypeScript source exists in RustBox" >&2
|
|
exit 1
|
|
fi
|
|
|
|
if ! git diff --quiet "$BASE..$TARGET_SHA" -- frontend/; then
|
|
if [ "$UI_REVIEWED" -ne 1 ]; then
|
|
echo "error: Oxi frontend changed between $BASE and $TARGET_SHA." >&2
|
|
echo "Review/port the relevant behavior, then rerun with --ui-reviewed." >&2
|
|
git diff --name-status "$BASE..$TARGET_SHA" -- frontend/ >&2 || true
|
|
exit 1
|
|
fi
|
|
fi
|
|
|
|
if ! git diff --quiet "$BASE..$TARGET_SHA" -- . ':(exclude)backend/**' ':(exclude)frontend/**'; then
|
|
if [ "$ROOT_REVIEWED" -ne 1 ]; then
|
|
echo "error: Oxi root-level files changed between $BASE and $TARGET_SHA." >&2
|
|
echo "Review relevant build/config/docs changes, then rerun with --root-reviewed." >&2
|
|
git diff --name-status "$BASE..$TARGET_SHA" -- . ':(exclude)backend/**' ':(exclude)frontend/**' >&2 || true
|
|
exit 1
|
|
fi
|
|
fi
|
|
|
|
if [ "$SKIP_BUILD" -ne 1 ]; then
|
|
./scripts/build-release.sh
|
|
else
|
|
echo "warning: build gate skipped by explicit --skip-build" >&2
|
|
fi
|
|
|
|
printf '%s\n' "$TARGET_SHA" > UPSTREAM_BASE
|
|
git add UPSTREAM_BASE
|
|
rm -f "$PENDING_FILE"
|
|
|
|
printf 'Oxi sync review completed: %s -> %s\n' "$BASE" "$TARGET_SHA"
|
|
printf 'UPSTREAM_BASE is staged. Review git status and commit the sync.\n'
|