Created
October 10, 2014 09:33
-
-
Save Mutix/e981e282a3d555048f8e to your computer and use it in GitHub Desktop.
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 | |
# | |
# An example hook script to check the commit log message. | |
# Called by "git commit" with one argument, the name of the file | |
# that has the commit message. The hook should exit with non-zero | |
# status after issuing an appropriate message if it wants to stop the | |
# commit. The hook is allowed to edit the commit message file. | |
# | |
## | |
# | |
# Checks if any files in the /Pods directory are staged with modifications | |
# | |
## | |
POD_INSTALL_MESSAGE="pod install"; | |
POD_UPDATE_MESSAGE="pod update"; | |
# $1 is the filename where the commit message text is held | |
if grep "$POD_INSTALL_MESSAGE" $1 ; then | |
installed_pods=1 | |
fi | |
if grep "$POD_UPDATE_MESSAGE" $1 ; then | |
updated_pods=1 | |
fi | |
PODS_SRC_PATTERN="/Pods/" | |
# Check the files being committed. | |
while read st file; do | |
file_dir=$(dirname ${file}) | |
file_name=$(basename ${file}) | |
if [[ $file_dir =~ $PODS_SRC_PATTERN ]] ; then | |
committing_pods=1 | |
echo "* File $file_name is in Pods directory: $file_dir" | |
fi | |
done <<EOT | |
$(git diff --cached --name-status) | |
EOT | |
if [ $committing_pods ]; then | |
if [ $installed_pods ] || [ $updated_pods ]; then | |
echo "" | |
echo "Well, OK, I guess you need to commit the Pods then..." | |
else | |
echo "" | |
echo "Error: Attempt to commit modified Pods!" | |
echo "" | |
echo "Modified pods should not be committed directly into the app repository..." | |
echo "" | |
echo "... UNLESS you have run a 'pod install' or 'pod update' to add new pods or update already used pods." | |
echo "" | |
echo "If you did in fact do a 'pod install' or 'pod update', then add either 'pod install' or 'pod update' to your commit message, and the commit will be accepted." | |
echo "" | |
echo "If a pod needs to be updated for a bug fix, feature change, etc, update the pod itself, publish a new version, and run 'pod install/update' in the client app rather than committing changes in the app repository and forgetting to bring them over to the actual pod repo itself!" | |
exit 1 | |
fi | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment