Skip to content

Instantly share code, notes, and snippets.

@bergantine
Last active February 18, 2016 12:57
Show Gist options
  • Save bergantine/3870080 to your computer and use it in GitHub Desktop.
Save bergantine/3870080 to your computer and use it in GitHub Desktop.
post-merge Git hook to install requirements if changed, compile stylesheets, syncdb, run a south migration on the database, and rebuild the haystack index using the active virtual environment's python installation. #bash #git #hook #django #compass #sass #pip #south #haystack
#!/bin/sh
if [ $(git diff HEAD@{1} HEAD --name-only | grep 'requirements/development.txt' -c) -ne 0 ]
then
sudo $VIRTUAL_ENV/bin/pip install -r /vagrant/myproject/requirements/development.txt
fi
compass compile /vagrant/myproject/myproject/static_media/stylesheets -e production --force
$VIRTUAL_ENV/bin/python /vagrant/myproject/manage.py syncdb
$VIRTUAL_ENV/bin/python /vagrant/myproject/manage.py migrate
if [ $(cat /vagrant/myproject/requirements/development.txt | grep 'haystack' -c) -ne 0 ]
then
$VIRTUAL_ENV/bin/python /vagrant/myproject/manage.py rebuild_index --noinput
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment