Skip to content

Instantly share code, notes, and snippets.

@sergio-bershadsky
Created October 30, 2014 10:00
Show Gist options
  • Select an option

  • Save sergio-bershadsky/79afb7bc36e223d37da0 to your computer and use it in GitHub Desktop.

Select an option

Save sergio-bershadsky/79afb7bc36e223d37da0 to your computer and use it in GitHub Desktop.
Simple script to track changes in repository
import os
import subprocess
DIR = os.path.dirname(os.path.abspath(__file__))
PYTHON = os.path.normpath(os.path.join(DIR, '../', 'env', 'bin', 'python'))
UPDATE_SCRIPT = os.path.normpath(os.path.join(DIR, 'update.py'))
GIT_HEAD = ['git', 'rev-list', 'HEAD', '--count']
GIT_PULL = ['git', 'pull']
UPDATE = [PYTHON, UPDATE_SCRIPT]
if __name__ == "__main__":
before_pull = subprocess.check_output(GIT_HEAD)
subprocess.call(GIT_PULL)
after_pull = subprocess.check_output(GIT_HEAD)
if before_pull != after_pull:
subprocess.call(UPDATE)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment