Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
git hook to update composer dependencies only if changed, and to put the current revision in a file
#set -x
OLD=`md5 -q composer.lock.old`
NEW=`md5 -q composer.lock`
if [ "$NEW" != "$OLD" ]
rm -rf vendor
php composer.phar install
cat composer.lock > composer.lock.old
b=$(git rev-parse --show-toplevel)
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

This comment has been minimized.

Copy link
Owner Author

yehosef commented Feb 3, 2015

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.


This comment has been minimized.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.