Skip to content

Instantly share code, notes, and snippets.

@boydgreenfield
Created March 27, 2015 01:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save boydgreenfield/fcfd8f81aea967550d27 to your computer and use it in GitHub Desktop.
Save boydgreenfield/fcfd8f81aea967550d27 to your computer and use it in GitHub Desktop.
team_sync.py
#!/usr/bin/env python
# Usage: python team_sync.py refgenomics Core [optional list of repos to sync (short name)]
from github import Github
import getpass
import sys
print "Enter user: ",
user = raw_input()
password = getpass.getpass()
g = Github(user, password)
org_name = sys.argv[1]
org = g.get_organization(org_name)
team = [x for x in org.get_teams() if x.name in sys.argv[2]][0]
repos = org.get_repos()
team_repos = [x for x in team.get_repos()]
for repo in repos:
if repo not in team_repos:
if len(sys.argv) > 3 and repo.name not in sys.argv[3:]:
continue
team.add_to_repos(repo)
print "Added %s to team %s" % (repo.full_name, team.name)
print ("Successfully sync'd %s repos (%s) to team %s" %
(org_name, "all" if len(sys.argv) <= 3 else " ".join(sys.argv[3:]), team.name))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment