From 182fede1b43d63280c137bfcb60b022be51953b5 Mon Sep 17 00:00:00 2001 From: Monty Taylor Date: Mon, 13 Feb 2017 09:36:04 -0600 Subject: [PATCH] Make a few less github API calls We continue to hit the GH rate limit. But honestly, in most cases, we should not need to make a bazillion GH api calls. Change-Id: Iac709a4f7f18d6348b21520bbc7aeacfa991ec1a --- jeepyb/cmd/manage_projects.py | 42 +++++++++++++---------------------- 1 file changed, 16 insertions(+), 26 deletions(-) diff --git a/jeepyb/cmd/manage_projects.py b/jeepyb/cmd/manage_projects.py index 1353a45..a86ec98 100644 --- a/jeepyb/cmd/manage_projects.py +++ b/jeepyb/cmd/manage_projects.py @@ -348,23 +348,6 @@ def create_update_github_project( try: repo = org.get_repo(repo_name) - # If necessary, update project on Github - if description and description != repo.description: - repo.edit(repo_name, description=description) - cache['description'] = description - if homepage and homepage != repo.homepage: - repo.edit(repo_name, homepage=homepage) - cache['homepage'] = homepage - if has_issues != repo.has_issues: - repo.edit(repo_name, has_issues=has_issues) - cache['has_issues'] = has_issues - if has_downloads != repo.has_downloads: - repo.edit(repo_name, has_downloads=has_downloads) - cache['has_downloads'] = has_downloads - if has_wiki != repo.has_wiki: - repo.edit(repo_name, has_wiki=has_wiki) - cache['has_wiki'] = has_wiki - except github.GithubException: repo = org.create_repo(repo_name, homepage=homepage, @@ -376,17 +359,24 @@ def create_update_github_project( cache['has_downloads'] = has_downloads cache['has_issues'] = has_issues - if description: - repo.edit(repo_name, description=description) - cache['description'] = description - if homepage: - repo.edit(repo_name, homepage=homepage) - cache['homepage'] = homepage - repo.edit(repo_name, has_issues=has_issues, - has_downloads=has_downloads, - has_wiki=has_wiki) created = True + kwargs = {} + # If necessary, update project on Github + if description and description != repo.description: + kwargs['description'] = description + if homepage and homepage != repo.homepage: + kwargs['homepage'] = homepage + if has_issues != repo.has_issues: + kwargs['has_issues'] = has_issues + if has_downloads != repo.has_downloads: + kwargs['has_downloads'] = has_downloads + if has_wiki != repo.has_wiki: + kwargs['has_wiki'] = has_wiki + + repo.edit(repo_name, **kwargs) + cache.update(kwargs) + if cache.get('gerrit-in-team', False): if 'gerrit' not in [team.name for team in repo.get_teams()]: teams = org.get_teams()