You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a pre-push script where I want to prompt the developers if they run their tests locally before they push their code:
#!/bin/sh# This hook prevents pushing if the build fails.# ANSI color codes for formatting
RED='\033[0;31m'
GREEN='\033[0;32m'
NC='\033[0m'# No Color# Ask the developer if they have run the tests locally# There is an issue hereecho"Have you run the tests locally? (y/n):"read REPLY
if [ "$REPLY"="n" ] || [ "$REPLY"="N" ];thenprintf"%s\n""${RED}error: Please run the tests locally before pushing.${NC}">&2exit 1
fi# Run your build command (replace with your actual build command)
build_command="docker build -f Dockerfile.prod -t esg-suite-prod:latest ."if!$build_command;thenprintf"%s\n""${RED}error: Build failed. Fix the build issues before pushing.${NC}">&2exit 1
elseprintf"%s\n""${GREEN}Build succeeded. Processing and Pushing...${NC}">&2exit 0
fi
The problem is passing directly to the build command without waiting to get the response (Y/N):
The text was updated successfully, but these errors were encountered:
you can get tty interaction working with something like exec < /dev/tty && ./myscript.sh ... but your hook still won't prompt the user if he uses a software like github desktop... my solution is to run the tests on pre-push on just the projects that changed in my monorepo
Yes, we have a pre-commit script for running tests for each changes made but some developers disable it and sometimes miss to run the tests and then push the code.
Do you recommend to add the test command in the pre-push script?
I have a pre-push script where I want to prompt the developers if they run their tests locally before they push their code:
The problem is passing directly to the build command without waiting to get the response (Y/N):
The text was updated successfully, but these errors were encountered: