Skip to content

Instantly share code, notes, and snippets.

@jayzeng
Last active December 19, 2015 13:09
Show Gist options
  • Save jayzeng/5960360 to your computer and use it in GitHub Desktop.
Save jayzeng/5960360 to your computer and use it in GitHub Desktop.
mat remote
#!/usr/bin/python
import subprocess
devs = {}
devs['jayzeng'] = 'jayzeng'
devs['niek'] = 'nieksand'
devs['lee'] = 'leehasoffers'
devs['lucas'] = 'lucasoffers'
devs['josh'] = 'joshs633'
devs['jack'] = 'jackofseattle'
devs['charles'] = 'charlesgardiner'
devs['kevin'] = 'kevin-hasoffers'
devs['nick'] = 'rushton'
devs['johnny'] = 'Johnny-Malizia'
# retrieve local username
whoami_cmd = subprocess.Popen(['whoami'], stdout=subprocess.PIPE)
local_username, err = whoami_cmd.communicate()
local_username = local_username.strip('\n')
for dev_name, dev_alias in devs.iteritems():
repos = ['app', 'api', 'schema']
for repo in repos:
base_repo = ('/data/www/%s') % repo
# set remote to match your username
if local_username in dev_name:
origin_alias = ('[email protected]:%s/%s.git') % (dev_alias, repo)
subprocess.Popen(['/usr/bin/git', 'remote', 'set-url', 'origin', origin_alias], cwd=base_repo)
prod_alias = ('[email protected]:Adapp/%s.git') % repo
repo_alias = ('[email protected]:%s/%s.git') % (dev_alias, repo)
subprocess.Popen(['/usr/bin/git', 'remote', 'add', dev_name, repo_alias], cwd=base_repo)
subprocess.Popen(['/usr/bin/git', 'remote', 'add', 'prod', prod_alias], cwd=base_repo)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment