Skip to content

Instantly share code, notes, and snippets.

@mythmon
Created November 18, 2013 23:11
Show Gist options
  • Save mythmon/7537074 to your computer and use it in GitHub Desktop.
Save mythmon/7537074 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
import os
import re
import subprocess
import requests
repo_dir = "{HOME}/src/kitsune".format(**os.environ)
environments = {
'dev': 'http://support-dev.allizom.org/media/revision.txt',
'stage': 'http://support.allizom.org/media/revision.txt',
'prod': 'http://support.mozilla.org/media/revision.txt',
}
def main():
cdpath = os.path.join(os.path.dirname(os.path.realpath(__file__)), '..')
os.chdir(cdpath)
git = Git()
print(git.fetch(all=True))
for env_name, revision_url in environments.items():
try:
cur_rev = git.rev_parse('deployed/' + env_name).strip()
except subprocess.CalledProcessError:
cur_rev = None
new_rev = requests.get(revision_url).text.strip()
if cur_rev != new_rev:
print 'updating ' + env_name, cur_rev[:8], new_rev[:8]
git.update_ref('refs/heads/deployed/' + env_name, new_rev)
if __name__ == '__main__':
main()
@bdauvergne
Copy link

The Git class import is missing.

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