You've already forked Commercialization.topon
简化Upm.bat脚本,移除冗余的错误处理和确认步骤,优化分支创建和标签推送流程,确保成功创建UPM分支和标签。
This commit is contained in:
128
Update Upm.bat
128
Update Upm.bat
@@ -1,124 +1,44 @@
|
|||||||
@echo off
|
@echo off
|
||||||
:: Set UTF-8 encoding
|
|
||||||
chcp 65001
|
chcp 65001
|
||||||
:: Set window title
|
|
||||||
title UPM Package Update Tool
|
|
||||||
:: Set console color
|
|
||||||
color a
|
color a
|
||||||
|
|
||||||
echo 开始提交到git upm....
|
echo Starting UPM package update...
|
||||||
echo 提交upm前请确保当前分支所有改动都已经提交!
|
echo Please make sure all changes are committed!
|
||||||
|
|
||||||
:: Extract version from package.json
|
:: Get version from package.json
|
||||||
for /f "tokens=2 delims=:, " %%i in ('findstr "version" Assets\package.json') do (
|
for /f "tokens=2 delims=:, " %%i in ('findstr "version" Assets\package.json') do (
|
||||||
set version=%%i
|
set version=%%i
|
||||||
)
|
)
|
||||||
:: Remove quotes
|
|
||||||
set version=%version:"=%
|
set version=%version:"=%
|
||||||
|
|
||||||
echo 从package.json中读取的版本号为:%version%
|
echo.
|
||||||
|
echo Current version: %version%
|
||||||
|
echo.
|
||||||
|
set /p confirm=Confirm to create UPM branch and tag %version% (y/n):
|
||||||
|
|
||||||
:: Check if tag exists
|
if /i not "%confirm%"=="y" (
|
||||||
git tag | findstr "%version%" > nul
|
echo Operation cancelled.
|
||||||
if %errorlevel% equ 0 (
|
goto :END
|
||||||
echo 错误:版本号 %version% 对应的tag已存在!
|
|
||||||
pause
|
|
||||||
exit
|
|
||||||
)
|
)
|
||||||
|
|
||||||
set /p Flg=确认提交的版本号%version%,是否开始提交(y/n) -------- :
|
:: Clean and prepare
|
||||||
|
git checkout -f master
|
||||||
|
git branch -D upm 2>nul
|
||||||
|
|
||||||
IF "%Flg%" equ "y" (
|
:: Create and push upm branch
|
||||||
echo 开始提交,请勿关闭该窗口!
|
git subtree split --prefix Assets --branch upm
|
||||||
|
git push -f origin upm
|
||||||
|
|
||||||
:: Force switch to master first and ensure clean state
|
:: Create and push tag
|
||||||
echo 切换到master分支并清理工作区...
|
git tag -d %version% 2>nul
|
||||||
git checkout -f master
|
git tag %version% upm
|
||||||
git reset --hard HEAD
|
git push origin %version%
|
||||||
git clean -fd
|
|
||||||
|
|
||||||
:: Verify Assets folder exists
|
:: Return to master
|
||||||
if not exist "Assets" (
|
git checkout -f master
|
||||||
echo 错误:Assets文件夹不存在!
|
|
||||||
goto :END
|
|
||||||
)
|
|
||||||
|
|
||||||
:: Delete local upm branch if exists
|
echo.
|
||||||
echo 清理本地upm分支...
|
echo Successfully created UPM branch and tag %version%
|
||||||
git branch -D upm 2>nul
|
|
||||||
|
|
||||||
:: Create new upm branch from current Assets folder with verbose output
|
|
||||||
echo 正在创建upm分支...
|
|
||||||
git subtree split --prefix Assets --branch upm --verbose
|
|
||||||
if %errorlevel% neq 0 (
|
|
||||||
echo 错误:创建upm分支失败!
|
|
||||||
echo 正在尝试修复...
|
|
||||||
|
|
||||||
:: Try to fix common issues
|
|
||||||
git gc
|
|
||||||
git prune
|
|
||||||
|
|
||||||
:: Second attempt
|
|
||||||
echo 第二次尝试创建upm分支...
|
|
||||||
git subtree split --prefix Assets --branch upm --verbose
|
|
||||||
if %errorlevel% neq 0 (
|
|
||||||
echo 错误:创建upm分支失败,请确保:
|
|
||||||
echo 1. Assets文件夹存在且不为空
|
|
||||||
echo 2. 当前分支没有未提交的更改
|
|
||||||
echo 3. Git仓库状态正常
|
|
||||||
goto :END
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
:: Force update local upm branch with remote changes
|
|
||||||
echo 更新远程upm分支...
|
|
||||||
git fetch origin upm
|
|
||||||
git checkout -f upm
|
|
||||||
git reset --hard origin/upm
|
|
||||||
|
|
||||||
:: Create new subtree split
|
|
||||||
git checkout -f master
|
|
||||||
git subtree split --prefix Assets --branch upm-temp
|
|
||||||
|
|
||||||
:: Apply new changes and force push
|
|
||||||
git checkout -f upm
|
|
||||||
git merge upm-temp --allow-unrelated-histories -X theirs
|
|
||||||
git branch -D upm-temp
|
|
||||||
|
|
||||||
:: Create and push tag with explicit steps
|
|
||||||
echo 创建并推送tag %version%...
|
|
||||||
git tag -d %version% 2>nul
|
|
||||||
git tag %version% upm
|
|
||||||
if %errorlevel% neq 0 (
|
|
||||||
echo 错误:创建tag失败!
|
|
||||||
git checkout -f master
|
|
||||||
goto :END
|
|
||||||
)
|
|
||||||
|
|
||||||
:: Push changes and tags separately
|
|
||||||
echo 推送upm分支...
|
|
||||||
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
|
|
||||||
echo 所有操作已完成!
|
|
||||||
)
|
|
||||||
|
|
||||||
:END
|
:END
|
||||||
echo 执行完成!
|
|
||||||
pause
|
pause
|
||||||
exit
|
|
||||||
Reference in New Issue
Block a user