Files
RustBox/scripts/setup-upstream.sh
T
Mateusz Gruszczyński bc5fbd6ba9
RustBox CI / rustbox (push) Waiting to run
first commit
2026-10-29 15:24:59 +01:00

42 lines
1.2 KiB
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
cd "$ROOT"
REMOTE="upstream-oxi"
URL="https://github.com/c0h1b4/oxi.git"
if ! git rev-parse --is-inside-work-tree >/dev/null 2>&1; then
echo "error: RustBox must be a Git checkout before configuring Oxi upstream." >&2
echo "Initialize it first:" >&2
echo " git init" >&2
echo " git add ." >&2
echo " git commit -m 'RustBox 0.0.1 baseline'" >&2
exit 1
fi
if git remote get-url "$REMOTE" >/dev/null 2>&1; then
current="$(git remote get-url "$REMOTE")"
if [ "$current" != "$URL" ]; then
echo "error: remote '$REMOTE' already points to: $current" >&2
echo "expected: $URL" >&2
exit 1
fi
else
git remote add "$REMOTE" "$URL"
fi
git fetch "$REMOTE" --tags
BASE="$(tr -d '[:space:]' < UPSTREAM_BASE)"
if ! git cat-file -e "$BASE^{commit}" 2>/dev/null; then
echo "error: recorded Oxi base commit is not available after fetch: $BASE" >&2
exit 1
fi
printf 'Oxi upstream configured.\n'
printf 'Remote: %s -> %s\n' "$REMOTE" "$URL"
printf 'Consumed Oxi baseline: %s\n' "$BASE"
printf 'Latest upstream-oxi/main: %s\n' "$(git rev-parse upstream-oxi/main)"