From 10644fae9568e1e072db86ba9553eae1dc552c28 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=9B=A8=E9=9C=96=E9=93=83?= Date: Fri, 5 Jun 2026 12:50:55 +0800 Subject: [PATCH] =?UTF-8?q?fix(hooks):=20pre-push=20=E6=97=A0=20upstream?= =?UTF-8?q?=20=E6=97=B6=E5=9B=9E=E9=80=80=E5=88=B0=20origin/main=20?= =?UTF-8?q?=E5=AF=B9=E6=AF=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .husky/pre-push | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.husky/pre-push b/.husky/pre-push index 1983b94..ff7b2f1 100644 --- a/.husky/pre-push +++ b/.husky/pre-push @@ -3,7 +3,9 @@ npx tsc --noEmit # ESLint 严格检查(仅检查本次推送的变更文件,不阻塞不相关的旧代码) -CHANGED_FILES=$(git diff --name-only --diff-filter=d @{upstream}...HEAD -- '*.ts' '*.tsx' '*.js' '*.jsx' '*.mjs') +# 新分支无 upstream 时,回退到与 origin/main 对比 +BASE=$(git rev-parse --verify @{upstream} 2>/dev/null && echo "@{upstream}" || echo "origin/main") +CHANGED_FILES=$(git diff --name-only --diff-filter=d "$BASE"...HEAD -- '*.ts' '*.tsx' '*.js' '*.jsx' '*.mjs') if [ -n "$CHANGED_FILES" ]; then echo "$CHANGED_FILES" | xargs npx eslint --max-warnings=0 fi