diff --git a/tests/base.py b/tests/base.py index 869835f204..3d7c457383 100644 --- a/tests/base.py +++ b/tests/base.py @@ -1096,7 +1096,8 @@ class FakeGithubPullRequest(object): }, 'sender': { 'login': 'ghuser' - } + }, + 'labels': [{'name': l} for l in self.labels] } return (name, data) diff --git a/tests/fakegithub.py b/tests/fakegithub.py index 93d280c442..3c73ebc22a 100644 --- a/tests/fakegithub.py +++ b/tests/fakegithub.py @@ -262,11 +262,6 @@ class FakeRepository(object): return pulls -class FakeLabel(object): - def __init__(self, name): - self.name = name - - class FakeIssue(object): def __init__(self, fake_pull_request): self._fake_pull_request = fake_pull_request @@ -274,10 +269,6 @@ class FakeIssue(object): def pull_request(self): return FakePull(self._fake_pull_request) - def labels(self): - return [FakeLabel(l) - for l in self._fake_pull_request.labels] - class FakeFile(object): def __init__(self, filename): @@ -338,6 +329,7 @@ class FakePull(object): 'merged': pr.is_merged, 'body': pr.body, 'changed_files': len(pr.files), + 'labels': [{'name': l} for l in pr.labels] } return data diff --git a/zuul/driver/github/githubconnection.py b/zuul/driver/github/githubconnection.py index 33bdc0d6e1..e75c3d9ebc 100644 --- a/zuul/driver/github/githubconnection.py +++ b/zuul/driver/github/githubconnection.py @@ -1132,10 +1132,6 @@ class GithubConnection(BaseConnection): self.log.warning("Pull request #%s of %s/%s returned None!" % ( number, owner, proj)) time.sleep(1) - # Get the issue obj so we can get the labels (this is silly) - # TODO: this may be able to be simplified after - # https://github.com/sigmavirus24/github3.py/issues/924 - issueobj = probj.issue() pr = probj.as_dict() try: pr['files'] = [f.filename for f in probj.files()] @@ -1147,10 +1143,8 @@ class GithubConnection(BaseConnection): "via the merger: %s", exc) pr['files'] = [] - pr['labels'] = [l.name for l in issueobj.labels()] - - self._sha_pr_cache.update(project_name, pr) - + labels = [l['name'] for l in pr['labels']] + pr['labels'] = labels log.debug('Got PR %s#%s', project_name, number) self.log_rate_limit(self.log, github) return (pr, probj)