Skip to content

Instantly share code, notes, and snippets.

@melizeche
Forked from nnja/post-merge
Created April 2, 2019 05:15
Show Gist options
  • Save melizeche/2976193406997ac087557e2e4c1b25c1 to your computer and use it in GitHub Desktop.
Save melizeche/2976193406997ac087557e2e4c1b25c1 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.'
@melizeche
Copy link
Author

melizeche commented Apr 2, 2019

To use this hook:
Copy it to .git/hooks/post-merge
Ensure it's executable with chmod +x .git/hooks/post-merge

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