Browse Source

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
tags/3.6.0
Tristan Cacqueray 5 months ago
parent
commit
ce94af3b3f
1 changed files with 3 additions and 2 deletions
  1. 3
    2
      zuul/driver/github/githubconnection.py

+ 3
- 2
zuul/driver/github/githubconnection.py View File

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

Loading…
Cancel
Save