Last active
December 21, 2015 04:18
-
-
Save saitodev/6247864 to your computer and use it in GitHub Desktop.
git post-receive example implemented in python.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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