mirror of
https://github.com/prowler-cloud/prowler.git
synced 2025-12-19 05:17:47 +00:00
refactor: simplify gga script and exclude api/ via config
This commit is contained in:
3
.gga
3
.gga
@@ -10,7 +10,8 @@ PROVIDER="claude"
|
|||||||
FILE_PATTERNS="*.ts,*.tsx,*.js,*.jsx,*.py"
|
FILE_PATTERNS="*.ts,*.tsx,*.js,*.jsx,*.py"
|
||||||
|
|
||||||
# File patterns to exclude from review (comma-separated globs)
|
# File patterns to exclude from review (comma-separated globs)
|
||||||
EXCLUDE_PATTERNS="*.test.ts,*.test.tsx,*.spec.ts,*.spec.tsx,*.d.ts,*_test.py,test_*.py,conftest.py"
|
# Excludes: test files, type definitions, and api/ folder (no AGENTS.md yet)
|
||||||
|
EXCLUDE_PATTERNS="*.test.ts,*.test.tsx,*.spec.ts,*.spec.tsx,*.d.ts,*_test.py,test_*.py,conftest.py,api/*"
|
||||||
|
|
||||||
# File containing your coding standards (relative to repo root)
|
# File containing your coding standards (relative to repo root)
|
||||||
RULES_FILE="AGENTS-CODE-REVIEW.md"
|
RULES_FILE="AGENTS-CODE-REVIEW.md"
|
||||||
|
|||||||
@@ -1,16 +1,12 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# Gentleman Guardian Angel (gga) - AI Code Review Hook
|
# Gentleman Guardian Angel (gga) - AI Code Review Hook
|
||||||
# This script is called by pre-commit after all formatters/linters have run
|
# This script is called by pre-commit after all formatters/linters have run
|
||||||
#
|
|
||||||
# Only reviews files in directories that have an AGENTS.md file.
|
|
||||||
# This allows teams to opt-in to AI code review by adding AGENTS.md to their component.
|
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
# Colors
|
# Colors
|
||||||
YELLOW='\033[1;33m'
|
YELLOW='\033[1;33m'
|
||||||
BLUE='\033[0;34m'
|
BLUE='\033[0;34m'
|
||||||
GREEN='\033[0;32m'
|
|
||||||
NC='\033[0m'
|
NC='\033[0m'
|
||||||
|
|
||||||
# Check if AI code review is enabled
|
# Check if AI code review is enabled
|
||||||
@@ -25,44 +21,6 @@ if [ ! -f "AGENTS-CODE-REVIEW.md" ]; then
|
|||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Get staged files
|
|
||||||
STAGED_FILES=$(git diff --cached --name-only --diff-filter=ACM | grep -E '\.(ts|tsx|js|jsx|py)$' || true)
|
|
||||||
|
|
||||||
if [ -z "$STAGED_FILES" ]; then
|
|
||||||
echo -e "${YELLOW}⏭️ No matching files staged for AI review${NC}"
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Filter out files from directories without AGENTS.md (opt-in model)
|
|
||||||
FILES_TO_REVIEW=""
|
|
||||||
SKIPPED_DIRS=""
|
|
||||||
|
|
||||||
for file in $STAGED_FILES; do
|
|
||||||
# Get the top-level directory of the file
|
|
||||||
TOP_DIR=$(echo "$file" | cut -d'/' -f1)
|
|
||||||
|
|
||||||
# Check if this directory has an AGENTS.md file
|
|
||||||
if [ -f "${TOP_DIR}/AGENTS.md" ]; then
|
|
||||||
FILES_TO_REVIEW="$FILES_TO_REVIEW $file"
|
|
||||||
else
|
|
||||||
# Track skipped directories (only unique)
|
|
||||||
if [[ ! "$SKIPPED_DIRS" =~ $TOP_DIR ]]; then
|
|
||||||
SKIPPED_DIRS="$SKIPPED_DIRS $TOP_DIR"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
# Report skipped directories
|
|
||||||
if [ -n "$SKIPPED_DIRS" ]; then
|
|
||||||
echo -e "${YELLOW}ℹ️ Skipping directories without AGENTS.md:${SKIPPED_DIRS}${NC}"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Check if there are files to review after filtering
|
|
||||||
if [ -z "$(echo "$FILES_TO_REVIEW" | tr -d ' ')" ]; then
|
|
||||||
echo -e "${GREEN}✅ No files to review (all staged files are in directories without AGENTS.md)${NC}"
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Install gga if not present
|
# Install gga if not present
|
||||||
if ! command -v gga &> /dev/null; then
|
if ! command -v gga &> /dev/null; then
|
||||||
echo -e "${BLUE}📦 Installing Gentleman Guardian Angel (gga)...${NC}"
|
echo -e "${BLUE}📦 Installing Gentleman Guardian Angel (gga)...${NC}"
|
||||||
@@ -87,4 +45,5 @@ if ! command -v gga &> /dev/null; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Run gga code review
|
# Run gga code review
|
||||||
|
# Exclusions are configured in .gga file (EXCLUDE_PATTERNS)
|
||||||
exec gga run
|
exec gga run
|
||||||
|
|||||||
Reference in New Issue
Block a user