Files
Uniglot/Hooks/scripts.d/find-data-files

31 lines
1.0 KiB
Bash
Executable File

#!/bin/bash
result=0
IFS="
"
originURL="$(git config remote.origin.url)"
homedir=0
if [[ "$originURL" =~ .*HomeDir.git$ ]]; then
homedir=1
fi
# We don't want to commit data files, with the exceptions being our GPG public key and organization logo in PNG & ASCII format.
for file in `git ls-files | xargs -d '\n' -n 1 file | grep -Ev 'ASCII text|JSON|empty|Unicode text|symbolic link|^Resources/logo.png|^Resources/ascii.txt|^Resources/public.gpg'`; do
#echo Evaluating \`"${file}"\`
filename="$(echo "${file}" | cut -f 1 -d ':')"
# Some databases need to be revision controlled to protect secrets, but these should only be committed to private repos.
if [ $homedir -eq 1 ] && [[ "$file" =~ GPG.keybox|Ansible.Vault|Keepass|^.gnupg/tofu.db ]]; then
continue
fi
if [ "$(du -k "${filename}" | awk '{ print $1; }')" -gt 10 ]; then
echo "$file"
result=1
fi
done
if [ $result -eq 1 ]; then
echo "These files need to be evaluated -- generally, don't commit data files to Git."
fi
exit $result