更新工具
parent
0367da9e1c
commit
dfb3ee270a
|
|
@ -13,6 +13,30 @@ SRC_DLL_PATH="$SCRIPT_DIR/../../WaitUpload"
|
||||||
# 目标路径
|
# 目标路径
|
||||||
TARGET_PATH="/Users/mayuanzheng/Documents/NoRemove/GamePlay_Dll"
|
TARGET_PATH="/Users/mayuanzheng/Documents/NoRemove/GamePlay_Dll"
|
||||||
|
|
||||||
|
# 定义函数用于清理 Git 锁文件
|
||||||
|
clean_git_locks() {
|
||||||
|
local repo_path="$1"
|
||||||
|
echo "Checking for Git lock files in $repo_path..."
|
||||||
|
|
||||||
|
# 清理索引锁文件
|
||||||
|
if [ -f "$repo_path/.git/index.lock" ]; then
|
||||||
|
echo "Found .git/index.lock, removing it..."
|
||||||
|
rm -f "$repo_path/.git/index.lock"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# 清理其他可能的锁文件
|
||||||
|
if [ -f "$repo_path/.git/HEAD.lock" ]; then
|
||||||
|
echo "Found .git/HEAD.lock, removing it..."
|
||||||
|
rm -f "$repo_path/.git/HEAD.lock"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# 检查 refs 目录下的锁文件
|
||||||
|
find "$repo_path/.git/refs" -name "*.lock" -type f 2>/dev/null | while read lockfile; do
|
||||||
|
echo "Found lock file: $lockfile, removing it..."
|
||||||
|
rm -f "$lockfile"
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
# 检查源路径是否存在
|
# 检查源路径是否存在
|
||||||
if [ ! -d "$SRC_DLL_PATH" ]; then
|
if [ ! -d "$SRC_DLL_PATH" ]; then
|
||||||
echo "Source path does not exist: $SRC_DLL_PATH"
|
echo "Source path does not exist: $SRC_DLL_PATH"
|
||||||
|
|
@ -87,6 +111,9 @@ if [ ! -d "$PROJECT_PATH" ]; then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# 清理项目仓库中的 Git 锁文件
|
||||||
|
clean_git_locks "$PROJECT_PATH"
|
||||||
|
|
||||||
# 切换到工程目录
|
# 切换到工程目录
|
||||||
cd "$PROJECT_PATH"
|
cd "$PROJECT_PATH"
|
||||||
if [ $? -ne 0 ]; then
|
if [ $? -ne 0 ]; then
|
||||||
|
|
@ -104,6 +131,8 @@ CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
|
||||||
git pull -X theirs
|
git pull -X theirs
|
||||||
if [ $? -ne 0 ]; then
|
if [ $? -ne 0 ]; then
|
||||||
echo "Warning: Failed to pull with strategy theirs, attempting hard reset..."
|
echo "Warning: Failed to pull with strategy theirs, attempting hard reset..."
|
||||||
|
# 清理可能的锁文件
|
||||||
|
clean_git_locks "$(pwd)"
|
||||||
# 如果 pull 失败,则执行强制重置为远端版本
|
# 如果 pull 失败,则执行强制重置为远端版本
|
||||||
git reset --hard origin/$CURRENT_BRANCH
|
git reset --hard origin/$CURRENT_BRANCH
|
||||||
if [ $? -ne 0 ]; then
|
if [ $? -ne 0 ]; then
|
||||||
|
|
@ -121,6 +150,9 @@ if [ ! -d "$PRIMARY_SUBMODULE_PATH" ]; then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# 在进入子模块目录前清理锁文件
|
||||||
|
clean_git_locks "$PROJECT_PATH/$PRIMARY_SUBMODULE_PATH"
|
||||||
|
|
||||||
# 进入子模块目录
|
# 进入子模块目录
|
||||||
cd "$PRIMARY_SUBMODULE_PATH"
|
cd "$PRIMARY_SUBMODULE_PATH"
|
||||||
if [ $? -ne 0 ]; then
|
if [ $? -ne 0 ]; then
|
||||||
|
|
@ -138,6 +170,7 @@ fi
|
||||||
|
|
||||||
# 回到项目根目录
|
# 回到项目根目录
|
||||||
cd "$PROJECT_PATH"
|
cd "$PROJECT_PATH"
|
||||||
|
clean_git_locks "$PROJECT_PATH"
|
||||||
|
|
||||||
# 提交主要子模块更新
|
# 提交主要子模块更新
|
||||||
git add "$PRIMARY_SUBMODULE_PATH"
|
git add "$PRIMARY_SUBMODULE_PATH"
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue