From 2857f2057d284b2508a7980591c6513402305307 Mon Sep 17 00:00:00 2001 From: irving Date: Tue, 4 Nov 2025 22:04:23 -0500 Subject: [PATCH] =?UTF-8?q?chore:=20=E6=9B=B4=E6=96=B0=E9=83=A8=E7=BD=B2?= =?UTF-8?q?=E8=84=9A=E6=9C=AC=20deploy-docker.sh?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- deploy-docker.sh | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/deploy-docker.sh b/deploy-docker.sh index 01f31a4..c349a11 100755 --- a/deploy-docker.sh +++ b/deploy-docker.sh @@ -7,9 +7,9 @@ cd "$SCRIPT_DIR" prompt_yes_no() { local prompt="$1" - local default_no_text="${2:-[y/N]}" + local choice_hint="${2:-[y/N]}" local answer - read -r -p "$prompt $default_no_text " answer || true + read -r -p "$prompt $choice_hint " answer || true answer="${answer:-}"; answer="${answer,,}" [[ "$answer" == "y" || "$answer" == "yes" ]] } @@ -27,15 +27,20 @@ if [[ "$CURRENT_BRANCH" != "master" ]]; then exit 1 fi -if ! prompt_yes_no "你跑测试了吗?要不要我帮你跑?"; then - echo "跳过测试执行。" +if prompt_yes_no "你跑测试了吗?确认已跑请输入 y"; then + echo "已确认测试执行完毕。" else - echo "开始执行测试: mvn test" - if ! mvn test; then - echo "测试未通过,部署流程终止。" + if prompt_yes_no "需要我帮你跑测试吗?"; then + echo "开始执行测试: mvn test" + if ! mvn test; then + echo "测试未通过,部署流程终止。" + exit 1 + fi + echo "测试通过。" + else + echo "错误: 未执行测试,部署流程终止。" exit 1 fi - echo "测试通过。" fi if ! prompt_yes_no "你备份数据库了吗?确认已备份请输入 y"; then @@ -53,6 +58,11 @@ if ! git -C "$SCRIPT_DIR" diff --quiet; then exit 1 fi +if [[ -n "$(git -C "$SCRIPT_DIR" ls-files --others --exclude-standard)" ]]; then + echo "错误: 检测到未跟踪的文件,请清理或加入版本控制后再试。" + exit 1 +fi + if ! git -C "$SCRIPT_DIR" diff --cached --quiet; then echo "错误: 检测到未提交的暂存修改,请提交后再试。" exit 1