Skip to content

Instantly share code, notes, and snippets.

@hrkokw
Created December 17, 2022 02:42
Embed
What would you like to do?
Git update hook example (poorly tested)
#!/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