Skip to content

Commit ca0f059

Browse files
committed
chore(security): fix sh-e incompatibility in pre-push hook (SonarQube and test blocks)
1 parent 0980e1a commit ca0f059

1 file changed

Lines changed: 8 additions & 6 deletions

File tree

.husky/pre-push

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@ echo "🔍 Starte Qualitäts-Checks vor dem Push..."
77

88
# 1. Schnelle Tests ausführen (Quality Gate – blockierend)
99
echo "⏳ Starte npm run test:fast..."
10-
LOG_LEVEL=warn npx vitest run --exclude tests/server/load-suite.test.ts --exclude tests/integration/serial-flow.test.ts
11-
if [ $? -ne 0 ]; then
10+
if LOG_LEVEL=warn npx vitest run --exclude tests/server/load-suite.test.ts --exclude tests/integration/serial-flow.test.ts; then
11+
echo "✅ Alle Tests bestanden"
12+
else
1213
echo "❌ Fehler: Die schnellen Tests sind fehlgeschlagen!"
1314
echo " → Tests reparieren, dann erneut pushen."
1415
exit 1
@@ -17,13 +18,14 @@ fi
1718
# 2. SonarQube Integration (optional - nur wenn Token gesetzt)
1819
if [ -n "$SONAR_TOKEN" ]; then
1920
echo "📡 Starte SonarQube Scan..."
20-
sonar-scanner -Dsonar.token=$SONAR_TOKEN -Dsonar.qualitygate.wait=false
21-
if [ $? -ne 0 ]; then
21+
# Wrap in if-condition to prevent sh -e from exiting on scanner failure (non-blocking)
22+
if sonar-scanner -Dsonar.token="$SONAR_TOKEN" -Dsonar.qualitygate.wait=false; then
23+
echo "✅ SonarQube Scan abgeschlossen"
24+
else
2225
echo "⚠️ Warnung: SonarQube Scan fehlgeschlagen (nicht blockierend)"
23-
# Nicht mit exit 1 abbrechen - SonarQube Fehler sollten Push nicht blockieren
2426
fi
2527
else
26-
echo "💡 Tipp: Um SonarQube zu aktivieren, setzen Sie: export SONAR_TOKEN=\"<token>\""
28+
echo "ℹ️ Kein SONAR_TOKEN gesetzt — SonarQube Scan übersprungen"
2729
fi
2830

2931
echo "✅ Pre-Push Checks abgeschlossen. Push wird fortgesetzt..."

0 commit comments

Comments
 (0)