Merge "github: prevent AttributeError when missing branch protection"
This commit is contained in:
commit
8034dc8408
|
@ -195,6 +195,10 @@ class FakeRepository(object):
|
||||||
|
|
||||||
def get_url_protection(self, branch):
|
def get_url_protection(self, branch):
|
||||||
contexts = self.data.required_contexts.get((self.name, 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 = {
|
data = {
|
||||||
'required_status_checks': {
|
'required_status_checks': {
|
||||||
'contexts': contexts
|
'contexts': contexts
|
||||||
|
|
|
@ -1116,7 +1116,7 @@ class GithubConnection(BaseConnection):
|
||||||
resp = github.session.get(url, headers=headers)
|
resp = github.session.get(url, headers=headers)
|
||||||
|
|
||||||
if resp.status_code == 404:
|
if resp.status_code == 404:
|
||||||
return None
|
return {}
|
||||||
|
|
||||||
return resp.json()
|
return resp.json()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue