claude-git-hooks 1.5.3 → 1.5.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +19 -0
- package/LICENSE +0 -0
- package/README.md +0 -0
- package/bin/claude-hooks +0 -0
- package/package.json +1 -1
- package/templates/CLAUDE_ANALYSIS_PROMPT_SONAR.md +0 -0
- package/templates/CLAUDE_PRE_COMMIT_SONAR.md +0 -0
- package/templates/CLAUDE_RESOLUTION_PROMPT.md +0 -1
- package/templates/check-version.sh +0 -0
- package/templates/pre-commit +78 -108
- package/templates/prepare-commit-msg +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,25 @@ Todos los cambios notables en este proyecto se documentarán en este archivo.
|
|
|
5
5
|
El formato está basado en [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
6
|
y este proyecto adhiere a [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [1.5.4] - 2024-12-22
|
|
9
|
+
|
|
10
|
+
### Fixed
|
|
11
|
+
|
|
12
|
+
- 🔧 **Generación de prompt de resolución en modo SonarQube**
|
|
13
|
+
- Ahora se genera correctamente `claude_resolution_prompt.md` cuando el Quality Gate falla
|
|
14
|
+
- El archivo se genera cuando hay `blockingIssues`, independiente del tipo de fallo
|
|
15
|
+
- Corregido el flujo para que siempre muestre los issues críticos antes de generar el prompt
|
|
16
|
+
|
|
17
|
+
- 🎯 **Unificación de lógica de análisis**
|
|
18
|
+
- Eliminada lógica duplicada entre modo "clásico" y SonarQube
|
|
19
|
+
- Ahora siempre se usa modo SonarQube (como se especificó en v1.4.1)
|
|
20
|
+
- Simplificación del flujo de decisión en el pre-commit hook
|
|
21
|
+
|
|
22
|
+
### Changed
|
|
23
|
+
|
|
24
|
+
- 📝 Refactorización del hook pre-commit para mayor claridad y mantenibilidad
|
|
25
|
+
- 🔄 La función `generate_resolution_prompt` ahora se llama consistentemente cuando hay issues bloqueantes
|
|
26
|
+
|
|
8
27
|
## [1.5.3] - 2025-09-12
|
|
9
28
|
|
|
10
29
|
### Fixed
|
package/LICENSE
CHANGED
|
File without changes
|
package/README.md
CHANGED
|
File without changes
|
package/bin/claude-hooks
CHANGED
|
File without changes
|
package/package.json
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/templates/pre-commit
CHANGED
|
@@ -332,125 +332,95 @@ if $CLAUDE_CLI < "$PROMPT_FILE" > "$RESPONSE_FILE" 2>&1; then
|
|
|
332
332
|
BLOCKING_ISSUES=$(echo "$JSON_RESPONSE" | jq -r '.blockingIssues[].description' 2>/dev/null | sed '/^$/d')
|
|
333
333
|
fi
|
|
334
334
|
|
|
335
|
+
# Always use SonarQube mode (as per v1.4.1)
|
|
335
336
|
QUALITY_GATE=$(echo "$JSON_RESPONSE" | jq -r '.QUALITY_GATE // ""' 2>/dev/null)
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
337
|
+
|
|
338
|
+
# Show SonarQube style results
|
|
339
|
+
echo
|
|
340
|
+
echo "╔════════════════════════════════════════════════════════════════════╗"
|
|
341
|
+
echo "║ CODE QUALITY ANALYSIS ║"
|
|
342
|
+
echo "╚════════════════════════════════════════════════════════════════════╝"
|
|
343
|
+
echo
|
|
344
|
+
|
|
345
|
+
# Quality Gate Status
|
|
346
|
+
if [ "$QUALITY_GATE" = "PASSED" ]; then
|
|
347
|
+
echo -e "${GREEN}✓ Quality Gate: PASSED${NC}"
|
|
348
|
+
else
|
|
349
|
+
echo -e "${RED}✗ Quality Gate: FAILED${NC}"
|
|
350
|
+
fi
|
|
351
|
+
echo
|
|
352
|
+
|
|
353
|
+
# Metrics
|
|
354
|
+
METRICS=$(echo "$JSON_RESPONSE" | jq -r '.metrics // {}' 2>/dev/null)
|
|
355
|
+
if [ "$METRICS" != "{}" ] && [ "$METRICS" != "null" ]; then
|
|
356
|
+
echo "📊 METRICS"
|
|
357
|
+
echo "├─ Reliability: $(echo "$METRICS" | jq -r '.reliability // "?"' 2>/dev/null)"
|
|
358
|
+
echo "├─ Security: $(echo "$METRICS" | jq -r '.security // "?"' 2>/dev/null)"
|
|
359
|
+
echo "├─ Maintainability: $(echo "$METRICS" | jq -r '.maintainability // "?"' 2>/dev/null)"
|
|
360
|
+
echo "├─ Coverage: $(echo "$METRICS" | jq -r '.coverage // "?"' 2>/dev/null)%"
|
|
361
|
+
echo "├─ Duplications: $(echo "$METRICS" | jq -r '.duplications // "?"' 2>/dev/null)%"
|
|
362
|
+
echo "└─ Complexity: $(echo "$METRICS" | jq -r '.complexity // "?"' 2>/dev/null)"
|
|
343
363
|
echo
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
364
|
+
fi
|
|
365
|
+
|
|
366
|
+
# Issues Summary
|
|
367
|
+
ISSUES=$(echo "$JSON_RESPONSE" | jq -r '.issues // {}' 2>/dev/null)
|
|
368
|
+
if [ "$ISSUES" != "{}" ] && [ "$ISSUES" != "null" ]; then
|
|
369
|
+
echo "📋 ISSUES SUMMARY"
|
|
370
|
+
BLOCKER=$(echo "$ISSUES" | jq -r '.blocker // 0' 2>/dev/null)
|
|
371
|
+
CRITICAL=$(echo "$ISSUES" | jq -r '.critical // 0' 2>/dev/null)
|
|
372
|
+
MAJOR=$(echo "$ISSUES" | jq -r '.major // 0' 2>/dev/null)
|
|
373
|
+
MINOR=$(echo "$ISSUES" | jq -r '.minor // 0' 2>/dev/null)
|
|
374
|
+
INFO=$(echo "$ISSUES" | jq -r '.info // 0' 2>/dev/null)
|
|
375
|
+
TOTAL=$((BLOCKER + CRITICAL + MAJOR + MINOR + INFO))
|
|
376
|
+
|
|
377
|
+
echo "Total: $TOTAL issues found"
|
|
378
|
+
[ "$BLOCKER" -gt 0 ] && echo -e " ${RED}🔴 Blocker: $BLOCKER${NC}"
|
|
379
|
+
[ "$CRITICAL" -gt 0 ] && echo -e " ${RED}🟠 Critical: $CRITICAL${NC}"
|
|
380
|
+
[ "$MAJOR" -gt 0 ] && echo -e " ${YELLOW}🟡 Major: $MAJOR${NC}"
|
|
381
|
+
[ "$MINOR" -gt 0 ] && echo " 🔵 Minor: $MINOR"
|
|
382
|
+
[ "$INFO" -gt 0 ] && echo " ⚪ Info: $INFO"
|
|
351
383
|
echo
|
|
352
|
-
|
|
353
|
-
# Metrics
|
|
354
|
-
METRICS=$(echo "$JSON_RESPONSE" | jq -r '.metrics // {}' 2>/dev/null)
|
|
355
|
-
if [ "$METRICS" != "{}" ] && [ "$METRICS" != "null" ]; then
|
|
356
|
-
echo "📊 METRICS"
|
|
357
|
-
echo "├─ Reliability: $(echo "$METRICS" | jq -r '.reliability // "?"' 2>/dev/null)"
|
|
358
|
-
echo "├─ Security: $(echo "$METRICS" | jq -r '.security // "?"' 2>/dev/null)"
|
|
359
|
-
echo "├─ Maintainability: $(echo "$METRICS" | jq -r '.maintainability // "?"' 2>/dev/null)"
|
|
360
|
-
echo "├─ Coverage: $(echo "$METRICS" | jq -r '.coverage // "?"' 2>/dev/null)%"
|
|
361
|
-
echo "├─ Duplications: $(echo "$METRICS" | jq -r '.duplications // "?"' 2>/dev/null)%"
|
|
362
|
-
echo "└─ Complexity: $(echo "$METRICS" | jq -r '.complexity // "?"' 2>/dev/null)"
|
|
363
|
-
echo
|
|
364
|
-
fi
|
|
365
|
-
|
|
366
|
-
# Issues Summary
|
|
367
|
-
ISSUES=$(echo "$JSON_RESPONSE" | jq -r '.issues // {}' 2>/dev/null)
|
|
368
|
-
if [ "$ISSUES" != "{}" ] && [ "$ISSUES" != "null" ]; then
|
|
369
|
-
echo "📋 ISSUES SUMMARY"
|
|
370
|
-
BLOCKER=$(echo "$ISSUES" | jq -r '.blocker // 0' 2>/dev/null)
|
|
371
|
-
CRITICAL=$(echo "$ISSUES" | jq -r '.critical // 0' 2>/dev/null)
|
|
372
|
-
MAJOR=$(echo "$ISSUES" | jq -r '.major // 0' 2>/dev/null)
|
|
373
|
-
MINOR=$(echo "$ISSUES" | jq -r '.minor // 0' 2>/dev/null)
|
|
374
|
-
INFO=$(echo "$ISSUES" | jq -r '.info // 0' 2>/dev/null)
|
|
375
|
-
TOTAL=$((BLOCKER + CRITICAL + MAJOR + MINOR + INFO))
|
|
376
|
-
|
|
377
|
-
echo "Total: $TOTAL issues found"
|
|
378
|
-
[ "$BLOCKER" -gt 0 ] && echo -e " ${RED}🔴 Blocker: $BLOCKER${NC}"
|
|
379
|
-
[ "$CRITICAL" -gt 0 ] && echo -e " ${RED}🟠 Critical: $CRITICAL${NC}"
|
|
380
|
-
[ "$MAJOR" -gt 0 ] && echo -e " ${YELLOW}🟡 Major: $MAJOR${NC}"
|
|
381
|
-
[ "$MINOR" -gt 0 ] && echo " 🔵 Minor: $MINOR"
|
|
382
|
-
[ "$INFO" -gt 0 ] && echo " ⚪ Info: $INFO"
|
|
383
|
-
echo
|
|
384
|
-
fi
|
|
385
|
-
|
|
386
|
-
# Detailed Issues
|
|
387
|
-
DETAILS_COUNT=$(echo "$JSON_RESPONSE" | jq -r '.details | length' 2>/dev/null)
|
|
388
|
-
if [ "$DETAILS_COUNT" -gt 0 ] 2>/dev/null; then
|
|
389
|
-
echo "🔍 DETAILED ISSUES"
|
|
390
|
-
echo "$JSON_RESPONSE" | jq -r '.details[]? |
|
|
391
|
-
"[\(.severity)] \(.type) in \(.file):\(.line // "?")\n \(.message)\n"' 2>/dev/null
|
|
392
|
-
fi
|
|
393
|
-
|
|
394
|
-
# Security Hotspots
|
|
395
|
-
HOTSPOTS=$(echo "$JSON_RESPONSE" | jq -r '.securityHotspots // 0' 2>/dev/null)
|
|
396
|
-
if [ "$HOTSPOTS" -gt 0 ] 2>/dev/null; then
|
|
397
|
-
echo "🔥 SECURITY HOTSPOTS: $HOTSPOTS found"
|
|
398
|
-
echo " Review security-sensitive code carefully"
|
|
384
|
+
fi
|
|
399
385
|
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
386
|
+
# Detailed Issues
|
|
387
|
+
DETAILS_COUNT=$(echo "$JSON_RESPONSE" | jq -r '.details | length' 2>/dev/null)
|
|
388
|
+
if [ "$DETAILS_COUNT" -gt 0 ] 2>/dev/null; then
|
|
389
|
+
echo "🔍 DETAILED ISSUES"
|
|
390
|
+
echo "$JSON_RESPONSE" | jq -r '.details[]? |
|
|
391
|
+
"[\(.severity)] \(.type) in \(.file):\(.line // "?")\n \(.message)\n"' 2>/dev/null
|
|
392
|
+
fi
|
|
393
|
+
|
|
394
|
+
# Security Hotspots
|
|
395
|
+
HOTSPOTS=$(echo "$JSON_RESPONSE" | jq -r '.securityHotspots // 0' 2>/dev/null)
|
|
396
|
+
if [ "$HOTSPOTS" -gt 0 ] 2>/dev/null; then
|
|
397
|
+
echo "🔥 SECURITY HOTSPOTS: $HOTSPOTS found"
|
|
398
|
+
echo " Review security-sensitive code carefully"
|
|
410
399
|
echo
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
400
|
+
fi
|
|
401
|
+
|
|
402
|
+
# Check if commit should be blocked
|
|
403
|
+
if [ "$QUALITY_GATE" = "FAILED" ] || [ "$APPROVED" = "false" ]; then
|
|
414
404
|
echo
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
if [ -n "$
|
|
405
|
+
error "❌ Commit blocked due to quality gate failure"
|
|
406
|
+
|
|
407
|
+
# Show blocking issues if they exist
|
|
408
|
+
if [ -n "$BLOCKING_ISSUES" ] && [ "$BLOCKING_ISSUES" != "null" ]; then
|
|
419
409
|
echo
|
|
420
|
-
echo "===
|
|
421
|
-
echo "$
|
|
422
|
-
fi
|
|
423
|
-
|
|
424
|
-
# Check if the commit should be blocked
|
|
425
|
-
if [ "$APPROVED" = "false" ]; then
|
|
426
|
-
error "❌ Commit rejected due to critical issues"
|
|
427
|
-
if [ -n "$BLOCKING_ISSUES" ] && [ "$BLOCKING_ISSUES" != "null" ]; then
|
|
428
|
-
echo
|
|
429
|
-
echo "=== CRITICAL ISSUES ==="
|
|
430
|
-
echo "$BLOCKING_ISSUES" | sed 's/^/- /'
|
|
431
|
-
|
|
432
|
-
# Generate AI-friendly resolution prompt
|
|
433
|
-
generate_resolution_prompt
|
|
434
|
-
fi
|
|
435
|
-
exit 1
|
|
410
|
+
echo "=== CRITICAL ISSUES ==="
|
|
411
|
+
echo "$BLOCKING_ISSUES" | sed 's/^/- /'
|
|
436
412
|
fi
|
|
437
413
|
|
|
438
|
-
#
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
echo
|
|
442
|
-
echo "=== ADDITIONAL DETAILS ==="
|
|
443
|
-
# If details is a string, print it directly
|
|
444
|
-
if echo "$DETAILS" | jq -e 'type == "string"' >/dev/null 2>&1; then
|
|
445
|
-
echo "$DETAILS" | jq -r '.'
|
|
446
|
-
# If it's an object or array, format it
|
|
447
|
-
else
|
|
448
|
-
echo "$DETAILS" | jq '.'
|
|
449
|
-
fi
|
|
414
|
+
# Generate AI-friendly resolution prompt if there are blocking issues
|
|
415
|
+
if [ "$BLOCKING_COUNT" -gt 0 ]; then
|
|
416
|
+
generate_resolution_prompt
|
|
450
417
|
fi
|
|
451
|
-
|
|
452
|
-
|
|
418
|
+
|
|
419
|
+
exit 1
|
|
453
420
|
fi
|
|
421
|
+
|
|
422
|
+
echo
|
|
423
|
+
log "✅ Code analysis completed. Quality gate passed."
|
|
454
424
|
|
|
455
425
|
else
|
|
456
426
|
error "Error executing Claude CLI"
|
|
File without changes
|