File size: 1,358 Bytes
8d0b310 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | #!/bin/sh
# sync.sh: rebase this Strix Halo fork onto the latest upstream DS4.
#
# Fetches antirez/ds4, runs the divergence policy check, then rebases the
# current branch onto upstream/main. Safe by default: it aborts if the working
# tree is dirty or if sync-check.sh would fail.
#
# Usage: misc/sync.sh [branch] (default branch: main)
set -e
BRANCH="${1:-main}"
UPSTREAM_REMOTE="${UPSTREAM_REMOTE:-upstream}"
UPSTREAM_REF="${UPSTREAM_REF:-main}"
cd "$(dirname "$0")/.."
if ! git remote get-url "$UPSTREAM_REMOTE" >/dev/null 2>&1; then
echo "sync: adding upstream remote $UPSTREAM_REMOTE -> antirez/ds4"
git remote add "$UPSTREAM_REMOTE" https://github.com/antirez/ds4.git
fi
if ! git diff --quiet || ! git diff --cached --quiet; then
echo "sync: working tree is dirty; commit or stash changes first." >&2
exit 1
fi
echo "sync: fetching upstream..."
git fetch "$UPSTREAM_REMOTE" "$UPSTREAM_REF"
if [ -f misc/sync-check.sh ]; then
echo "sync: running divergence policy check (pre-rebase)..."
sh misc/sync-check.sh || {
echo "sync: sync-check.sh failed; refusing to rebase." >&2
exit 1
}
fi
echo "sync: rebasing $BRANCH onto $UPSTREAM_REMOTE/$UPSTREAM_REF..."
git rebase "$UPSTREAM_REMOTE/$UPSTREAM_REF" "$BRANCH"
echo "sync: done. Review the result, then 'git push --force-with-lease origin $BRANCH'."
|