From 48ee4671a7ee5618f45a3f39b65b1fd978cf46ea Mon Sep 17 00:00:00 2001 From: Joseph Schorr Date: Tue, 16 Jun 2015 15:46:58 -0400 Subject: [PATCH] Some additional fixes when testing this branch --- endpoints/trigger.py | 44 +++++++++++++++++++++++++++++--------------- 1 file changed, 29 insertions(+), 15 deletions(-) diff --git a/endpoints/trigger.py b/endpoints/trigger.py index e87264c4b..db4ccd91e 100644 --- a/endpoints/trigger.py +++ b/endpoints/trigger.py @@ -765,7 +765,7 @@ class GithubBuildTrigger(BuildTriggerHandler): commit_info['author']['url'] = sender.get('html_url', '') if 'committer' in head_commit: - commit_info['author'] = { + commit_info['committer'] = { 'username': head_commit['committer'].get('username'), } @@ -960,25 +960,39 @@ class GithubBuildTrigger(BuildTriggerHandler): config = self.config if field_name == 'tag_name': - gh_client = self._get_client() - source = config['build_source'] - repo = gh_client.get_repo(source) - return [tag.name for tag in repo.get_tags()] + try: + gh_client = self._get_client() + source = config['build_source'] + repo = gh_client.get_repo(source) + return [tag.name for tag in repo.get_tags()] + except GitHubBadCredentialsException: + return [] + except GithubException: + logger.exception("Got GitHub Exception when trying to list tags for trigger %s", + self.trigger.id) + return [] if field_name == 'branch_name': - gh_client = self._get_client() - source = config['build_source'] - repo = gh_client.get_repo(source) - branches = [branch.name for branch in repo.get_branches()] + try: + gh_client = self._get_client() + source = config['build_source'] + repo = gh_client.get_repo(source) + branches = [branch.name for branch in repo.get_branches()] - if not repo.default_branch in branches: - branches.insert(0, repo.default_branch) + if not repo.default_branch in branches: + branches.insert(0, repo.default_branch) - if branches[0] != repo.default_branch: - branches.remove(repo.default_branch) - branches.insert(0, repo.default_branch) + if branches[0] != repo.default_branch: + branches.remove(repo.default_branch) + branches.insert(0, repo.default_branch) - return branches + return branches + except GitHubBadCredentialsException: + return ['master'] + except GithubException: + logger.exception("Got GitHub Exception when trying to list branches for trigger %s", + self.trigger.id) + return ['master'] return None