Last active
August 30, 2021 11:47
-
-
Save sergeyhush/c0c09642ca76ddd67c53 to your computer and use it in GitHub Desktop.
Post-receive git hook to check if file changed
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 | |
WATCH_FILE="abc.123" | |
while read oldrev newrev refname; do | |
if [ "$refname" = "refs/heads/master" ]; then | |
if git diff-tree --name-only -r -z $oldrev $newrev | grep --quiet $WATCH_FILE ; then | |
# WATCH_FILE changed... | |
fi | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
will search any substring which may be part of filename, soo it return true for 'foo${WATCH_FILE}bar'
! git diff-tree --exit-code --name-only -r -z $oldrev $newrev -- "$WATCH_FILE"
note: exit code will be 1 if $WATCH_FILE changed