Last active
December 18, 2015 13:59
-
-
Save Bockit/5794123 to your computer and use it in GitHub Desktop.
Simple script to sync labels to any repository. Usage: python synclabels.py owner/repo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import argparse | |
from getpass import getuser, getpass | |
from github3 import GitHub | |
user = raw_input('GitHub username: ') | |
password = '' | |
while not password: | |
password = getpass('Password for %s: ' % user) | |
print 'Signing in...' | |
g = GitHub(user, password) | |
print 'Signed in.' | |
parser = argparse.ArgumentParser() | |
parser.add_argument('repo', help='The repo you want to sync labels for. In the format owner/repo') | |
repo = parser.parse_args().repo | |
owner = repo.split('/')[0] | |
repo = repo.split('/')[1] | |
print 'Getting repository.' | |
repo = g.repository(owner, repo) | |
labels = { | |
'invalid': '#ffffff', | |
'unassigned': '#ffffff', | |
'data': '#ffffff', | |
'feature': '#ffffff', | |
'bug': '#ffffff', | |
'must': '#ffffff', | |
'should': '#ffffff', | |
'could': '#ffffff', | |
'wont': '#ffffff', | |
'urgent': '#ff0000', | |
} | |
labels = [{'name': k, 'color': labels[k]} for k in labels.keys()] | |
print 'Deleting labels' | |
for label in repo.iter_labels(): | |
print 'Deleting %s' % label | |
label.delete() | |
print 'Creating labels' | |
for label in labels: | |
print 'Creating %s' % label | |
repo.create_label(**label) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment