github: do not use protected=0 to get all project's branches

It seems like github.com api now skips protected branch when using the
protected=0 branches query parameter. This results in protected branch
being skipped when a tenant doesn't set the exclude-unprotected-branches
option. This change fixes this issue by setting protected=1 only
when we need to exclude_unprotected branches.

The protected parameter behavior can be observed with these URLs:

https://api.github.com/repos/ansible/zuul-config/branches
-> returns all the branches

https://api.github.com/repos/ansible/zuul-config/branches?protected=1
-> returns only the protected branch

https://api.github.com/repos/ansible/zuul-config/branches?protected=0
-> returns only the unprotected branch

Change-Id: I7e749eb723b02ec9a6f4b6193e727c35165a6b76
This commit is contained in:
Tristan Cacqueray 2019-01-26 03:43:19 +00:00
parent 76ac47442f
commit ce94af3b3f
1 changed files with 3 additions and 2 deletions

View File

@ -1018,8 +1018,9 @@ class GithubConnection(BaseConnection):
'branches')
headers = {'Accept': 'application/vnd.github.loki-preview+json'}
protected = 1 if exclude_unprotected else 0
params = {'per_page': 100, 'protected': protected}
params = {'per_page': 100}
if exclude_unprotected:
params['protected'] = 1
branches = []
while url: