Merge "github: prevent AttributeError when missing branch protection"

This commit is contained in:
Zuul 2018-07-11 20:55:45 +00:00 committed by Gerrit Code Review
commit 8034dc8408
2 changed files with 5 additions and 1 deletions

View File

@ -195,6 +195,10 @@ class FakeRepository(object):
def get_url_protection(self, branch):
contexts = self.data.required_contexts.get((self.name, branch), [])
if not contexts:
# Note that GitHub returns 404 if branch protection is off so do
# the same here as well
return FakeResponse({}, 404)
data = {
'required_status_checks': {
'contexts': contexts

View File

@ -1116,7 +1116,7 @@ class GithubConnection(BaseConnection):
resp = github.session.get(url, headers=headers)
if resp.status_code == 404:
return None
return {}
return resp.json()