mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2026-01-29 08:45:41 +08:00
chore: light hook
This commit is contained in:
@@ -1,26 +1,24 @@
|
||||
#!/bin/bash
|
||||
set -euo pipefail
|
||||
|
||||
# $1: remote name (e.g., origin)
|
||||
# $2: remote url (e.g., git@github.com:clash-verge-rev/clash-verge-rev.git)
|
||||
remote_name="$1"
|
||||
|
||||
# --- Rust clippy for staged files in src-tauri ---
|
||||
if git diff --cached --name-only | grep -q '^src-tauri/'; then
|
||||
cargo clippy --manifest-path ./src-tauri/Cargo.toml -- -D warnings
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Clippy found issues in src-tauri. Please fix them before pushing."
|
||||
echo "[pre-push] Running clippy on src-tauri..."
|
||||
cargo clippy --manifest-path ./src-tauri/Cargo.toml -- -D warnings || {
|
||||
echo "❌ Clippy found issues in src-tauri. Please fix them before pushing."
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
fi
|
||||
|
||||
|
||||
# Only run format check if the remote exists and is the main repo
|
||||
remote_name="$1"
|
||||
# --- JS/TS format check only for main repo ---
|
||||
if git remote get-url "$remote_name" >/dev/null 2>&1; then
|
||||
remote_url=$(git remote get-url "$remote_name")
|
||||
if [[ "$remote_url" =~ github\\.com[:/]+clash-verge-rev/clash-verge-rev(\\.git)?$ ]]; then
|
||||
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
|
||||
if ! pnpm format:check; then
|
||||
echo "❌ Code format check failed. Please fix formatting before pushing."
|
||||
exit 1
|
||||
fi
|
||||
@@ -28,7 +26,8 @@ if git remote get-url "$remote_name" >/dev/null 2>&1; then
|
||||
echo "[pre-push] Not pushing to target repo. Skipping format check."
|
||||
fi
|
||||
else
|
||||
echo "[pre-push] Remote $remote_name does not exist. Skipping format check."
|
||||
echo "[pre-push] Remote '$remote_name' does not exist. Skipping format check."
|
||||
fi
|
||||
|
||||
echo "[pre-push] All checks passed."
|
||||
exit 0
|
||||
|
||||
Reference in New Issue
Block a user