优化Upm.bat脚本,添加强制切换分支、错误处理和分开推送tag的功能,确保推送过程中的稳定性和可靠性。

This commit is contained in:
2025-03-13 18:13:18 +08:00
parent 7370d9cfcf
commit bcd23a28a0

View File

@@ -31,33 +31,63 @@ set /p Flg=确认提交的版本号%version%,是否开始提交(y/n) --------
IF "%Flg%" equ "y" ( IF "%Flg%" equ "y" (
echo 开始提交,请勿关闭该窗口! echo 开始提交,请勿关闭该窗口!
:: Force switch to master first
git checkout -f master
:: Delete local upm branch if exists :: Delete local upm branch if exists
git branch -D upm 2>nul git branch -D upm 2>nul
:: Create new upm branch from current Assets folder :: Create new upm branch from current Assets folder
git subtree split --prefix=Assets --branch upm git subtree split --prefix=Assets --branch upm
if %errorlevel% neq 0 (
echo 错误创建upm分支失败
goto :END
)
:: Force update local upm branch with remote changes :: Force update local upm branch with remote changes
git fetch origin upm git fetch origin upm
git checkout upm git checkout -f upm
git reset --hard origin/upm git reset --hard origin/upm
:: Create new subtree split :: Create new subtree split
git checkout master git checkout -f master
git subtree split --prefix=Assets --branch upm-temp git subtree split --prefix=Assets --branch upm-temp
:: Apply new changes and force push :: Apply new changes and force push
git checkout upm git checkout -f upm
git merge upm-temp --allow-unrelated-histories -X theirs git merge upm-temp --allow-unrelated-histories -X theirs
git branch -D upm-temp git branch -D upm-temp
:: Create and push tag :: Create and push tag with explicit steps
echo 创建并推送tag %version%...
git tag -d %version% 2>nul
git tag %version% upm git tag %version% upm
git push -f origin upm --tags if %errorlevel% neq 0 (
echo 错误创建tag失败
git checkout -f master
goto :END
)
:: Return to original branch :: Push changes and tags separately
git checkout master echo 推送upm分支...
GOTO :END git push -f origin upm
if %errorlevel% neq 0 (
echo 错误推送upm分支失败
git checkout -f master
goto :END
)
echo 推送tag...
git push origin %version%
if %errorlevel% neq 0 (
echo 错误推送tag失败
git tag -d %version%
git checkout -f master
goto :END
)
:: Return to master branch
git checkout -f master
) )
:END :END