feat: enhance pre-push hook to include remote URL check and improve format check messaging

This commit is contained in:
Tunglies
2025-06-18 18:49:48 +08:00
parent f3ad6cee41
commit 357b64e9a0
3 changed files with 25 additions and 7 deletions

View File

@@ -8,12 +8,20 @@ if git diff --cached --name-only | grep -q '^src-tauri/'; then
fi
fi
if [[ "$(git rev-parse --show-toplevel)" == */clash-verge-rev/clash-verge-rev ]]; then
remote_name="$1"
remote_url=$(git remote get-url "$remote_name")
if [[ "$remote_url" =~ github\.com[:/]+clash-verge-rev/clash-verge-rev(\.git)?$ ]]; then
echo "[pre-push] Detected push to clash-verge-rev/clash-verge-rev ($remote_url)"
echo "[pre-push] Running pnpm format:check..."
pnpm format:check
if [ $? -ne 0 ]; then
echo "Code format check failed. Please fix formatting before pushing."
echo "Code format check failed. Please fix formatting before pushing."
exit 1
fi
else
echo "[pre-push] Not pushing to target repo. Skipping format check."
fi
exit 0