Created
December 17, 2022 02:42
-
-
Save hrkokw/658c6f27e9f8d2930aceda219d01d0fb to your computer and use it in GitHub Desktop.
Git update hook example (poorly tested)
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/sh | |
refname="$1" | |
oldrev="$2" | |
newrev="$3" | |
function test_exif { | |
local commit="$1" path="$2" | |
echo "${path}" | egrep -iq '\.(jpe?g|png)$' || return 0 | |
if ! which exiftool >/dev/null 2>&1; then | |
echo >&2 "ExifTool is not installed on the server" | |
return 1 | |
fi | |
if git show "${commit}:${path}" | exiftool - | egrep -q '^GPS'; then | |
echo >&2 "${commit:0:8}:${path} seems to have GPS metadata" | |
return 1 | |
fi | |
return 0 | |
} | |
IFS=$'\n' | |
errors=0 | |
for commit in $( git show --format=format:%H --quiet ${oldrev}..${newrev} ); do | |
for path in $( git diff --name-only ${commit}^..${commit} ); do | |
test_exif ${commit} "${path}" || ((errors++)) | |
done | |
done | |
exit ${errors} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment