Created
June 16, 2021 13:55
-
-
Save eric-khoury/0b2f6568287aac6b9e5b6b73147ccfa6 to your computer and use it in GitHub Desktop.
script used as a git pre-commit script to see if any data-testid has changed in the DOM in the commit
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
RED='\033[1;31m' | |
YELLOW='\033[0;33m' | |
END_COLOR='\e[0m' | |
currentCommit=$(git show -s --format=%H) | |
numOfLinesChangedWithTestIds=$(git diff $currentCommit~ $currentCommit -G testid --stat | wc -l) | |
filesChanged=$(git diff $currentCommit~ $currentCommit -G testid --name-only ':(exclude)changedTestIds.sh') | |
if (( $numOfLinesChangedWithTestIds > 0 )); | |
then | |
printf "${RED}\n\n\n🔥🔥🔥🚨-----> YOU HAVE CHANGED A TEST ID <-----🚨🔥🔥🔥\n\n${END_COLOR}" | |
printf "${YELLOW}-> ${filesChanged}${END_COLOR}\n\n\n" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment