Ensure github change body is not a NoneType
The test framework was already operating in this way, but this changes it to reflect that we might get pull requests without a body (description). Without this, we'd attempt to run a regex on a None type which causes a traceback. Change-Id: Ibabf6452bd7d0c6df071227d8a3dc2e32f36158e
This commit is contained in:
parent
3e78572327
commit
152a402493
|
@ -554,7 +554,7 @@ class FakeGithubPullRequest(object):
|
|||
|
||||
def __init__(self, github, number, project, branch,
|
||||
subject, upstream_root, files=[], number_of_commits=1,
|
||||
writers=[], body=''):
|
||||
writers=[], body=None):
|
||||
"""Creates a new PR with several commits.
|
||||
Sends an event about opened PR."""
|
||||
self.github = github
|
||||
|
@ -880,7 +880,7 @@ class FakeGithubConnection(githubconnection.GithubConnection):
|
|||
self.reports = []
|
||||
|
||||
def openFakePullRequest(self, project, branch, subject, files=[],
|
||||
body=''):
|
||||
body=None):
|
||||
self.pr_number += 1
|
||||
pull_request = FakeGithubPullRequest(
|
||||
self, self.pr_number, project, branch, subject, self.upstream_root,
|
||||
|
@ -1051,7 +1051,11 @@ class FakeGithubConnection(githubconnection.GithubConnection):
|
|||
(self.git_host, change.project.name,
|
||||
change.number))
|
||||
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
|
||||
pull = self.getPull(pr.project, pr.number)
|
||||
prs.append(pull)
|
||||
|
|
|
@ -595,6 +595,9 @@ class GithubConnection(BaseConnection):
|
|||
change.number)
|
||||
change.labels = change.pr.get('labels')
|
||||
change.body = change.pr.get('body')
|
||||
# ensure body is at least an empty string
|
||||
if not change.body:
|
||||
change.body = ''
|
||||
|
||||
if history is None:
|
||||
history = []
|
||||
|
|
Loading…
Reference in New Issue