)]}'
{"zuul/driver/github/githubconnection.py":[{"author":{"_account_id":16068,"name":"Tobias Henkel","email":"tobias.henkel@bmw.de","username":"tobias.henkel"},"change_message_id":"c74cb0b9e3b238d15f51dbe5cc2267558111f700","unresolved":false,"context_lines":[{"line_number":1032,"context_line":""},{"line_number":1033,"context_line":"            for branch in resp.json():"},{"line_number":1034,"context_line":"                if exclude_unprotected:"},{"line_number":1035,"context_line":"                    detail \u003d self.getBranch(project.name, branch[\u0027name\u0027])"},{"line_number":1036,"context_line":"                    if detail and detail[\u0027protected\u0027]:"},{"line_number":1037,"context_line":"                        branches.append(branch[\u0027name\u0027])"},{"line_number":1038,"context_line":"                else:"}],"source_content_type":"text/x-python","patch_set":1,"id":"bfdaf3ff_7cee7789","line":1035,"updated":"2019-01-11 16:21:44.000000000","message":"This will have a bad effect on loading performance with many projects and many branches. E.g. in our deployment this will create hundreds to thousands of additional requests during startup or reconfiguration.\n\nCan you double check (maybe post an example request) that this returns the protection information? If yes we should think about whether it makes sense to query first with the protected flag and if that doesn\u0027t work fall back to this approach.","commit_id":"b5c22b72aaf63aa853b58a9103e3e6ebe3c12c9b"},{"author":{"_account_id":16068,"name":"Tobias Henkel","email":"tobias.henkel@bmw.de","username":"tobias.henkel"},"change_message_id":"db185b2e0326d6f971717b10e54a25013152e52c","unresolved":false,"context_lines":[{"line_number":1021,"context_line":"        # logic."},{"line_number":1022,"context_line":"        resp \u003d github.session.get(url, headers\u003dheaders, params\u003dparams)"},{"line_number":1023,"context_line":"        if exclude_unprotected and resp.status_code \u003d\u003d 404:"},{"line_number":1024,"context_line":"            params[\u0027protected\u0027] \u003d 0"},{"line_number":1025,"context_line":""},{"line_number":1026,"context_line":"        branches \u003d []"},{"line_number":1027,"context_line":"        while url:"}],"source_content_type":"text/x-python","patch_set":3,"id":"bfdaf3ff_42edb7ed","line":1024,"updated":"2019-01-14 06:50:59.000000000","message":"This still causes one extra request per project in the normal case. I think it\u0027s possible to do this fallback directly in the while loop (see below).","commit_id":"95e732aff6e348f3a3535c433ccd1929af9be751"},{"author":{"_account_id":16068,"name":"Tobias Henkel","email":"tobias.henkel@bmw.de","username":"tobias.henkel"},"change_message_id":"db185b2e0326d6f971717b10e54a25013152e52c","unresolved":false,"context_lines":[{"line_number":1038,"context_line":"                    self.log.warning("},{"line_number":1039,"context_line":"                        \"Rate limit exceeded, using empty branch list\")"},{"line_number":1040,"context_line":"                return []"},{"line_number":1041,"context_line":""},{"line_number":1042,"context_line":"            # Fall back to use combo querying to get protected branches"},{"line_number":1043,"context_line":"            if exclude_unprotected and params[\u0027protected\u0027] \u003d\u003d 0:"},{"line_number":1044,"context_line":"                for branch in resp.json():"}],"source_content_type":"text/x-python","patch_set":3,"id":"bfdaf3ff_e2bb8be2","line":1041,"updated":"2019-01-14 06:50:59.000000000","message":"Something like this here:\n\n if params[\u0027protected\u0027] and resp.status_code \u003d\u003d 404:\n     params[\u0027protected\u0027] \u003d 0\n     resp \u003d github.session.get(...)\n     url \u003d resp.links.get(...)","commit_id":"95e732aff6e348f3a3535c433ccd1929af9be751"},{"author":{"_account_id":16068,"name":"Tobias Henkel","email":"tobias.henkel@bmw.de","username":"tobias.henkel"},"change_message_id":"ef890383fe0d7d3e1b03cdb72ebcfd3a837d07a2","unresolved":false,"context_lines":[{"line_number":1031,"context_line":"            # NOTES: If we set protected\u003d1 to list branched, but no"},{"line_number":1032,"context_line":"            # repository admin permission, github API will raise 404."},{"line_number":1033,"context_line":"            # Fall back to use combo querying to get protected branches."},{"line_number":1034,"context_line":"            if (resp.status_code \u003d\u003d 404 or"},{"line_number":1035,"context_line":"                    (exclude_unprotected and params[\u0027protected\u0027] \u003d\u003d 0)):"},{"line_number":1036,"context_line":"                if params[\u0027protected\u0027]:"},{"line_number":1037,"context_line":"                    params[\u0027protected\u0027] \u003d 0"}],"source_content_type":"text/x-python","patch_set":4,"id":"bfdaf3ff_04a57804","line":1034,"updated":"2019-01-14 10:08:30.000000000","message":"I\u0027d find it much easier to read if we structure it like this:\n\n  while url:\n      resp \u003d github.session.get(\n          url, headers\u003dheaders, params\u003dparams)\n\n\n      if resp.status_code \u003d\u003d 403:\n          self.log.error(str(resp))\n          rate_limit \u003d github.rate_limit()\n          if rate_limit[\u0027resources\u0027][\u0027core\u0027][\u0027remaining\u0027] \u003d\u003d 0:\n              self.log.warning(\n                  \"Rate limit exceeded, using empty branch list\")\n          return []\n\n\n      # NOTES: If we set protected\u003d1 to list branched, but no\n      # repository admin permission, github API will raise 404 so we try\n      # again with no filter and filter ourselve.\n      if resp.status_code \u003d\u003d 404 and params[\u0027protected\u0027]:\n          params[\u0027protected\u0027] \u003d 0\n          resp \u003d github.session.get(\n              url, headers\u003dheaders, params\u003dparams)\n\n\n      # Fall back to use combo querying to get protected branches.\n      if exclude_unprotected and params[\u0027protected\u0027] \u003d\u003d 0:\n          for branch in resp.json():\n              detail \u003d self.getBranch(project.name, branch[\u0027name\u0027])\n              if detail and detail[\u0027protected\u0027]:\n                  branches.append(branch[\u0027name\u0027])\n      else:\n          branches.extend([x[\u0027name\u0027] for x in resp.json()])\n\n\n      # check if we need to do further paged calls\n      url \u003d resp.links.get(\u0027next\u0027, {}).get(\u0027url\u0027)","commit_id":"e3fdd7a853dba5453ab8b5fe4b67a511c0ca38b8"},{"author":{"_account_id":8276,"name":"kiwik","email":"chenrui.momo@gmail.com","username":"kiwik"},"change_message_id":"f530527d420ca3c7cfdc4190a562152bfb0246e5","unresolved":false,"context_lines":[{"line_number":1031,"context_line":"            # NOTES: If we set protected\u003d1 to list branched, but no"},{"line_number":1032,"context_line":"            # repository admin permission, github API will raise 404."},{"line_number":1033,"context_line":"            # Fall back to use combo querying to get protected branches."},{"line_number":1034,"context_line":"            if (resp.status_code \u003d\u003d 404 or"},{"line_number":1035,"context_line":"                    (exclude_unprotected and params[\u0027protected\u0027] \u003d\u003d 0)):"},{"line_number":1036,"context_line":"                if params[\u0027protected\u0027]:"},{"line_number":1037,"context_line":"                    params[\u0027protected\u0027] \u003d 0"}],"source_content_type":"text/x-python","patch_set":4,"id":"bfdaf3ff_5db25fe8","line":1034,"in_reply_to":"bfdaf3ff_04a57804","updated":"2019-01-15 07:36:12.000000000","message":"Done","commit_id":"e3fdd7a853dba5453ab8b5fe4b67a511c0ca38b8"}]}
