Last active
December 19, 2016 09:28
-
-
Save yehosef/8ffbab1f2dbbef22b757 to your computer and use it in GitHub Desktop.
git hook to update composer dependencies only if changed, and to put the current revision in a file
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/bash | |
#set -x | |
githooks/post-checkout-revision.sh | |
githooks/post-checkout-composer.sh |
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/bash | |
OLD=`md5 -q composer.lock.old` | |
NEW=`md5 -q composer.lock` | |
if [ "$NEW" != "$OLD" ] | |
then | |
rm -rf vendor | |
php composer.phar install | |
fi | |
cat composer.lock > composer.lock.old |
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/bash | |
b=$(git rev-parse --show-toplevel) | |
output_file=$b/docroot/www/revision.txt | |
branch=`git rev-parse --abbrev-ref HEAD ` | |
revision=`git rev-parse HEAD` | |
echo -e "$branch $revision \n" > $output_file | |
current_date=`date +%A\ %F\ %r` | |
echo "Checkout at:$current_date" >>$output_file | |
last_commit_at=`git log -1 HEAD --date=local --decorate --pretty=format:"%cd"` | |
echo "Last commit at: $last_commit_at " >>$output_file |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
you should add the composer.lock to the repo and add composer.lock.old to the .gitignore.
When you want to manually do an update, just run composer update and the commit the lock file.