Skip to content

Instantly share code, notes, and snippets.

@zats
Last active January 3, 2016 14:19
Show Gist options
  • Save zats/8475621 to your computer and use it in GitHub Desktop.
Save zats/8475621 to your computer and use it in GitHub Desktop.
Git hook to run pod install automatically upon checkout if Podfile change comparing to the last commit
# Existent podfile
current_directory="${PWD}"
current_podfile_path="$current_directory/Podfile"
current_directory_md5=`md5 -q -s "$current_directory"`
temporary_podfile_path="/tmp/${current_directory_md5}.podfile"
echo "Comparing Podfiles\nOld: $current_podfile_path\nNew: $temporary_podfile_path"
# Comparing it to the new Podfile
comparison_result=`comm -1 -3 -i $current_podfile_path $temporary_podfile_path`
if [ comparison_result == "" ]; then
echo "No changes in Podfile detected"
else
echo "Podfile changed"
cd code
pod install
fi
# Copy the current Podfile to the temporary directory
cp -f "$current_podfile_path" $temporary_podfile_path
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment