android-samples/hooks/pre-commit
Enrique López Mañas 273126a7c7
chore: improved git hook to add Google API Keys (#1576)
* chore: improved git hook to add Google API Keys

* chore: updated Gradle
2024-05-17 05:10:18 -06:00

15 lines
486 B
Bash

#!/bin/bash
## This hook provides an example that prevents the API Key from being committed.
## The file can be adapted to your needs, but ultimately this hook will reject the commit if the MAPS_API_KEY
## has been modified. Git Hooks are located in the folder .git/hooks
FILE="local.defaults.properties"
API_KEY_REGEX="AIza[0-9A-Za-z\-_]{35}"
if grep -qE "^MAPS_API_KEY=$API_KEY_REGEX" "$FILE"; then
echo "Error: Commit rejected. Invalid content in $FILE."
exit 1
fi
exit 0