Merge "Ensure github change body is not a NoneType" into feature/zuulv3

This commit is contained in:
Jenkins 2017-07-07 20:00:58 +00:00 committed by Gerrit Code Review
commit aa8fad9bac
2 changed files with 10 additions and 3 deletions

View File

@ -554,7 +554,7 @@ class FakeGithubPullRequest(object):
def __init__(self, github, number, project, branch, def __init__(self, github, number, project, branch,
subject, upstream_root, files=[], number_of_commits=1, subject, upstream_root, files=[], number_of_commits=1,
writers=[], body=''): writers=[], body=None):
"""Creates a new PR with several commits. """Creates a new PR with several commits.
Sends an event about opened PR.""" Sends an event about opened PR."""
self.github = github self.github = github
@ -880,7 +880,7 @@ class FakeGithubConnection(githubconnection.GithubConnection):
self.reports = [] self.reports = []
def openFakePullRequest(self, project, branch, subject, files=[], def openFakePullRequest(self, project, branch, subject, files=[],
body=''): body=None):
self.pr_number += 1 self.pr_number += 1
pull_request = FakeGithubPullRequest( pull_request = FakeGithubPullRequest(
self, self.pr_number, project, branch, subject, self.upstream_root, self, self.pr_number, project, branch, subject, self.upstream_root,
@ -1051,7 +1051,11 @@ class FakeGithubConnection(githubconnection.GithubConnection):
(self.server, change.project.name, (self.server, change.project.name,
change.number)) change.number))
for pr in self.pull_requests: for pr in self.pull_requests:
if pattern.search(pr.body): if not pr.body:
body = ''
else:
body = pr.body
if pattern.search(body):
# Get our version of a pull so that it's a dict # Get our version of a pull so that it's a dict
pull = self.getPull(pr.project, pr.number) pull = self.getPull(pr.project, pr.number)
prs.append(pull) prs.append(pull)

View File

@ -608,6 +608,9 @@ class GithubConnection(BaseConnection):
change.number) change.number)
change.labels = change.pr.get('labels') change.labels = change.pr.get('labels')
change.body = change.pr.get('body') change.body = change.pr.get('body')
# ensure body is at least an empty string
if not change.body:
change.body = ''
if history is None: if history is None:
history = [] history = []