ensure rev sync

This commit is contained in:
InkerBot
2026-03-05 15:48:21 +08:00
parent 629b8c3066
commit daba0d704e
5 changed files with 74 additions and 6 deletions
+27 -2
View File
@@ -6,10 +6,35 @@ ROOT="$(dirname "$SCRIPT_DIR")"
SING_BOX="$ROOT/works/sing-box"
PATCH_DIR="$ROOT/works/patch"
OUTPUT="$ROOT/works/core"
REV_FILE="$ROOT/works/rev"
# defaults
REPO_URL="git@git.inker.bot:arknights/sing-box.git"
UPSTREAM_BRANCH="main"
CONFIG="$ROOT/works/config"
if [ -f "$CONFIG" ]; then
. "$CONFIG"
fi
# Clone if not present
if [ ! -d "$SING_BOX/.git" ]; then
echo "Error: works/sing-box not found. Run update first." >&2
exit 1
echo "Cloning sing-box..."
if [ -n "$UPSTREAM_BRANCH" ]; then
git clone -b "$UPSTREAM_BRANCH" "$REPO_URL" "$SING_BOX"
else
git clone "$REPO_URL" "$SING_BOX"
fi
fi
# Checkout stored rev
if [ -f "$REV_FILE" ]; then
REV="$(cat "$REV_FILE" | tr -d '[:space:]')"
echo "Checking out stored rev: $REV"
git -C "$SING_BOX" fetch --all
git -C "$SING_BOX" checkout "$REV"
else
echo "Warning: works/rev not found, using current HEAD." >&2
fi
echo "Initializing works/core/..."