From 262bd6808b5d8c05410c6738fe7e0b87e04a47fb Mon Sep 17 00:00:00 2001 From: jxxghp Date: Thu, 16 Apr 2026 16:51:44 +0800 Subject: [PATCH] update reused bootstrap repo before setup --- scripts/bootstrap-local.sh | 43 +++++++++++++++++++++++++++++++------- 1 file changed, 36 insertions(+), 7 deletions(-) diff --git a/scripts/bootstrap-local.sh b/scripts/bootstrap-local.sh index 042052ae..347936f0 100755 --- a/scripts/bootstrap-local.sh +++ b/scripts/bootstrap-local.sh @@ -3,6 +3,7 @@ set -euo pipefail REPO_URL="https://github.com/jxxghp/MoviePilot.git" +REPO_REF="v2" WORKDIR="$PWD" APP_DIR_NAME="MoviePilot" LINK_CLI="true" @@ -43,6 +44,40 @@ Examples: EOF } +repo_dirty() { + ( + cd "$1" + git status --porcelain 2>/dev/null | grep -q . + ) +} + +sync_repo() { + if [[ ! -d "$APP_DIR/.git" ]]; then + echo "==> 克隆 MoviePilot 到 $APP_DIR" + git clone --branch "$REPO_REF" "$REPO_URL" "$APP_DIR" + return + fi + + echo "==> 复用已有 MoviePilot 仓库: $APP_DIR" + if repo_dirty "$APP_DIR"; then + echo "检测到现有仓库包含未提交改动,已停止自动更新。" >&2 + echo "请先清理 $APP_DIR 的本地修改,或换一个新的安装目录后重试。" >&2 + exit 1 + fi + + ( + cd "$APP_DIR" + echo "==> 更新本地仓库到 origin/$REPO_REF" + git fetch --tags origin "$REPO_REF" + if git show-ref --verify --quiet "refs/heads/$REPO_REF"; then + git checkout "$REPO_REF" + else + git checkout -b "$REPO_REF" "origin/$REPO_REF" + fi + git pull --ff-only origin "$REPO_REF" + ) +} + default_config_dir() { case "$OS_NAME" in macOS) @@ -359,13 +394,7 @@ fi mkdir -p "$WORKDIR" WORKDIR="$(cd "$WORKDIR" && pwd)" APP_DIR="$WORKDIR/$APP_DIR_NAME" - -if [[ ! -d "$APP_DIR/.git" ]]; then - echo "==> 克隆 MoviePilot 到 $APP_DIR" - git clone "$REPO_URL" "$APP_DIR" -else - echo "==> 复用已有 MoviePilot 仓库: $APP_DIR" -fi +sync_repo cd "$APP_DIR" echo "==> 执行本地环境安装与初始化"