diff --git a/.husky/pre-commit b/.husky/pre-commit index 885c1d5d1d..ed9f5f7348 100644 --- a/.husky/pre-commit +++ b/.husky/pre-commit @@ -1,4 +1,4 @@ -# Check if there are staged changes in the frontend directory +# Check for changes in frontend directory if git diff --cached --name-only | grep -q '^agenta-web/'; then cd agenta-web || exit @@ -18,6 +18,22 @@ fi if git diff --cached --name-only | grep -q '^agenta-backend/'; then cd agenta-backend || exit + # Run black for formatting + if ! black --check .; then + echo '⚠️ Formatting issues detected. Running black to fix them...' + black . + + # Stage the fixed files + git add . + + echo '✅ Formatting issues fixed and changes staged.' + fi +fi + +# Check for changes in cli directory +if git diff --cached --name-only | grep -q '^agenta-cli/'; then + cd agenta-cli || exit + # Run black for formatting if ! black --check .; then echo '⚠️ Formatting issues detected. Running black to fix them...' diff --git a/.husky/pre-push b/.husky/pre-push index a8370a917f..8eeb110f10 100644 --- a/.husky/pre-push +++ b/.husky/pre-push @@ -22,7 +22,20 @@ if git diff --name-only --cached origin/$(git rev-parse --abbrev-ref HEAD) | gre cd agenta-backend || exit # Run backend checks - if ! pylint $(git diff --cached --name-only | grep '\.py$'); then + if ! pylint --recursive=y --errors-only .; then + echo '❌ pylint issues detected. Please fix them before pushing the code.' + exit 1 + fi + + echo '🎉 Backend checks passed. Ready to push!' +fi + +# Check cli changes +if git diff --name-only --cached origin/$(git rev-parse --abbrev-ref HEAD) | grep -q '^agenta-cli/'; then + cd agenta-cli || exit + + # Run backend checks + if ! pylint --recursive=y --errors-only .; then echo '❌ pylint issues detected. Please fix them before pushing the code.' exit 1 fi