Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
git hook to update composer dependencies only if changed, and to put the current revision in a file
#!/bin/bash
#set -x
githooks/post-checkout-revision.sh
githooks/post-checkout-composer.sh
#!/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
#!/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
@yehosef

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.

@yehosef

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.