Skip to content

Instantly share code, notes, and snippets.

@ggarza
Created August 7, 2015 02:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ggarza/a1c6ccb6b8212028bfec to your computer and use it in GitHub Desktop.
Save ggarza/a1c6ccb6b8212028bfec to your computer and use it in GitHub Desktop.
Small python script to update vcs repos
#!/usr/bin/env python
#from http://djangosnippets.org/snippets/844/
import os
import os.path
from subprocess import call
if __name__ == "__main__":
apps_dir = os.path.abspath('.')
for app_name in os.listdir(apps_dir):
app_dir = os.path.abspath(os.path.join(apps_dir, app_name))
git_path = os.path.join(app_dir, '.git')
svn_path = os.path.join(app_dir, '.svn')
hg_path = os.path.join(app_dir, '.hg')
bzr_path = os.path.join(app_dir, '.bzr')
if os.path.lexists(svn_path):
print "Updating svn %s" % app_dir
os.chdir(app_dir)
call(['svn', 'update'])
elif os.path.lexists(git_path):
print "Updating git %s" % app_dir
os.chdir(app_dir)
call(['git', 'pull', '--rebase'])
elif os.path.lexists(hg_path):
print "Updating hg %s" % app_dir
os.chdir(app_dir)
call(['hg', 'pull', '-u'])
elif os.path.lexists(bzr_path):
print "Updating bzr %s" % app_dir
os.chdir(app_dir)
try:
call(['bzr', 'pull'])
except:
call(['ls'])
else:
continue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment