1
0
mirror of https://github.com/DSPBluePrints/FactoryBluePrints.git synced 2025-12-08 21:13:29 +08:00
Files
FactoryBluePrints/update.sh
2025-08-09 17:26:21 +08:00

43 lines
1.1 KiB
Bash
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/bash
# This script is used to manually fetch blueprints from remote
LOG_PATH="update.log"
REMOTE_URI="git@github.com:DSPBluePrints/FactoryBluePrints.git"
cd "$(dirname "$0")"
# debug info
ls > $LOG_PATH
echo "----" >> $LOG_PATH
# test dir
if [ ! -d "../../Blueprint" ]; then
echo "$(date '+%x %X') Warning: Abnormal installation path" >> "$LOG_PATH"
echo "警告:您似乎安装到了错误的路径,这可能导致文件权限异常"
fi
# test git
# git should already be installed as a package
if git --version &> /dev/null; then
echo "$(date '+%x %X') Infomation: GIT_PATH=$(command -v git)"
else
echo "错误无法找到git"
echo "$(date '+%x %X') Error: git not found" >> "$LOG_PATH"
exit 1
fi
# find .git
if [ ! -d ".git" ]; then
echo "警告:无法找到.git"
echo "$(date '+%x %X') Warning: .git not found" >> "$LOG_PATH"
git init
git remote add origin $REMOTE_URI
fi
# force-reset
git remote set-url origin $REMOTE_URI
git fetch --all
git reset --hard origin/main
echo "$(date '+%x %X') Information : git reset --hard" >> "$LOG_PATH"
# git clean -fd