29 lines
940 B
Bash
29 lines
940 B
Bash
#!/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
|
|
echo "Clippy found issues in src-tauri. Please fix them before pushing."
|
|
exit 1
|
|
fi
|
|
fi
|
|
|
|
# 只在 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
|
|
if [ $? -ne 0 ]; then
|
|
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
|