Merge "Use oauth token to create GitHub project if available"

This commit is contained in:
Jenkins 2016-03-10 21:21:21 +00:00 committed by Gerrit Code Review
commit 3a9b21810c
1 changed files with 5 additions and 3 deletions

View File

@ -297,9 +297,11 @@ def create_github_project(
secure_config = ConfigParser.ConfigParser()
secure_config.read(github_secure_config)
# Project creation doesn't work via oauth
ghub = github.Github(secure_config.get("github", "username"),
secure_config.get("github", "password"))
if secure_config.has_option("github", "oauth_token"):
ghub = github.Github(secure_config.get("github", "oauth_token"))
else:
ghub = github.Github(secure_config.get("github", "username"),
secure_config.get("github", "password"))
orgs = ghub.get_user().get_orgs()
orgs_dict = dict(zip([o.login.lower() for o in orgs], orgs))