From 35cedf85479b7cfe1a5e2d715da7f023bed62247 Mon Sep 17 00:00:00 2001 From: Matt Prahl Date: Mon, 7 Aug 2017 21:07:11 +0000 Subject: [PATCH] Fix up the owner-sync script. --- .../backend/templates/owner-sync-pagure.j2 | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/roles/bodhi2/backend/templates/owner-sync-pagure.j2 b/roles/bodhi2/backend/templates/owner-sync-pagure.j2 index 47c78df466..dea8f89ec9 100755 --- a/roles/bodhi2/backend/templates/owner-sync-pagure.j2 +++ b/roles/bodhi2/backend/templates/owner-sync-pagure.j2 @@ -144,7 +144,9 @@ def get_pagure_projects(namespace): while url: response = requests.get(url, verify=VERIFY).json() for project in response['projects']: - yield project + # Skip forks + if not project['fullname'].startswith('forks/'): + yield project url = response['pagination']['next'] @@ -154,11 +156,17 @@ def get_project_ownership(tag, namespace): # Check if this project has the branch we are interested in project_branches_url = '{0}api/0/{1}/{2}/git/branches'.format( PAGURE_URL, namespace, project['name']) - project_branches_rv = \ - requests.get(project_branches_url, verify=VERIFY).json() + project_branches_rv = requests.get(project_branches_url, verify=VERIFY) + + # If the project's branches can't be reported, let's skip the project + # for now. + if not project_branches_rv.ok: + continue + + project_branches_rv_json = project_branches_rv.json() # The tag and branch names are the same for "old-style" branches - if tag in project_branches_rv['branches']: + if tag in project_branches_rv_json['branches']: # Although this is a list, Pagure only supports one owner for now projects[project['name']] = project['access_users']['owner'][0]