Skip to content

Instantly share code, notes, and snippets.

@saitodev
Last active December 21, 2015 04:18
Show Gist options
  • Save saitodev/6247864 to your computer and use it in GitHub Desktop.
Save saitodev/6247864 to your computer and use it in GitHub Desktop.
git post-receive example implemented in python.
#!/usr/local/bin/python
# -*- coding: utf-8; mode: python -*-
import os
import os.path
import sys
import subprocess
WORK_DIR = '/path/to/work/dir'
GIT_DIR = os.path.join(WORK_DIR, '.git')
def main():
hash1, hash2, ref = sys.stdin.readline().split()
if ref == 'refs/heads/release':
os.chdir(WORK_DIR)
subprocess.check_call(['git', '--git-dir={0}'.format(GIT_DIR), 'pull'])
# Do something
return
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment