From e1bb8aa125314a58822d857c1ced9a44cf0aa3fd Mon Sep 17 00:00:00 2001 From: Tunglies <77394545+Tunglies@users.noreply.github.com> Date: Fri, 27 Jun 2025 00:36:00 +0800 Subject: [PATCH] chore(pre-push): update comments for clarity and refine format check condition --- .husky/pre-push | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/.husky/pre-push b/.husky/pre-push index e7b0a02e9..dfa2bf734 100644 --- a/.husky/pre-push +++ b/.husky/pre-push @@ -1,5 +1,8 @@ #!/bin/bash +# $1: remote name (e.g., origin) +# $2: remote url (e.g., git@github.com:clash-verge-rev/clash-verge-rev.git) + if git diff --cached --name-only | grep -q '^src-tauri/'; then cargo clippy --manifest-path ./src-tauri/Cargo.toml if [ $? -ne 0 ]; then @@ -8,9 +11,9 @@ if git diff --cached --name-only | grep -q '^src-tauri/'; then fi fi -# 检查所有 remote url 是否有目标仓库 -if git remote -v | grep -Eq 'github\\.com[:/]+clash-verge-rev/clash-verge-rev(\\.git)?'; then - echo "[pre-push] Detected push to clash-verge-rev/clash-verge-rev" +# 只在 push 到 origin 并且 origin 指向目标仓库时执行格式检查 +if [ "$1" = "origin" ] && echo "$2" | grep -Eq 'github\.com[:/]+clash-verge-rev/clash-verge-rev(\.git)?$'; then + echo "[pre-push] Detected push to origin (clash-verge-rev/clash-verge-rev)" echo "[pre-push] Running pnpm format:check..." pnpm format:check