I trim the space from git using git diff-index --check --cached HEAD -- . I want to add Jest tests using snapshots, but the snapshot files include spaces, and my tests will always fail if I delete it. Therefore, I want to exclude *.js.snap files from the space check. How to tell git to exclude *.js.snap files (or, alternatively, **/__snapshots/* ) from git diff-index ? I am using bash on OSX.
At the same time, I am working on a problem, changing my commit hook to interactive:
# If there are whitespace errors, print the offending file names and fail. git diff-index --check --cached HEAD -- if [ $? -ne 0 ]; then # Allows us to read user input below, assigns stdin to keyboard exec < /dev/tty while true; do echo "Your commit introduces trailing whitespace. Are you sure you want to commit? y/n" read yn case $yn in y ) exit 0;; n ) exit 1;; esac done fi
git whitespace githooks jestjs
undefined
source share