Skip to content

Instantly share code, notes, and snippets.

@nnja
Created October 2, 2017 01:19
Show Gist options
  • Save nnja/5ce68f0312caf6607bba15dde2c28f02 to your computer and use it in GitHub Desktop.
Save nnja/5ce68f0312caf6607bba15dde2c28f02 to your computer and use it in GitHub Desktop.
Git Hook: Example post-merge hook that checks for updates to requirements.txt
#!/usr/bin/env python
import sys
import subprocess
diff_requirements = 'git diff ORIG_HEAD HEAD --exit-code -- requirements.txt'
exit_code = subprocess.call(diff_requirements.split())
if exit_code == 1:
print 'The requirements file has changed! Remember to install new dependencies.'
else:
print 'No new dependencies.'
@MuhammadFarag
Copy link

Thank you 👍

@dev-msln
Copy link

dev-msln commented Dec 4, 2019

I would like to run some commands after git pull for django project.

as you know, developers use virtual environment for developing django projects. So I should use the python used in project virtual environment.
how to handle this?
I want to run python manage.py migrate and pip install requirements.txt after git pull.

thanks.

@lastmaj
Copy link

lastmaj commented Oct 20, 2022

@mojtabasalehiyan if by some chance you are still looking for a possible answer, then maybe creating a bash scripts that activates your virtual environments and then creates migration could solve your problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment