Skip to content

Instantly share code, notes, and snippets.

@yehosef
Last active December 19, 2016 09:28
Show Gist options
  • Save yehosef/8ffbab1f2dbbef22b757 to your computer and use it in GitHub Desktop.
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
#!/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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment