diff --git a/compile.sh b/compile.sh index f81be70..74932d8 100755 --- a/compile.sh +++ b/compile.sh @@ -12,6 +12,24 @@ echo "Build process started at $(date)" | tee $LOGFILE # 获取当前分支名 current_branch=$(git rev-parse --abbrev-ref HEAD) +# 打包之前,需要检查是否在 dev 分支,工作区是否干净,是否和远程分支一致 +if [ "$(git branch --show-current)" != "dev" ]; then + echo "当前分支不是 dev 分支" + exit 1 +fi + +# 检查工作区是否干净 +if [ -n "$(git status --porcelain)" ]; then + echo "工作区不干净" + exit 1 +fi + +# 检查远程分支是否和本地分支一致 +if [ "$(git rev-parse HEAD)" != "$(git rev-parse origin/dev)" ]; then + echo "本地分支和远程分支不一致" + exit 1 +fi + # 检查当前分支并运行相应的 npm 命令 if [ "$current_branch" = "dev" ]; then echo "On dev branch, building project..." | tee -a $LOGFILE