Modify owner-sync-pagure to use the releng user as the owner in Koji

This commit is contained in:
ralph 2017-08-11 00:22:29 +00:00 committed by Ralph Bean
parent a8d59c5678
commit bf97b87714

View file

@ -160,18 +160,17 @@ def get_repo_name_and_arches(tag, version):
def get_pagure_projects(session, namespace):
url = urljoin(PAGURE_URL, 'api/0/projects?namespace={0}'.format(namespace))
url = url + "&page=1&per_page=50"
url = url + "&page=1&per_page=50&fork=false&short=true"
while url:
response = session.get(url, verify=VERIFY, timeout=120)
if not bool(response):
print("Failed to talk to %r %r." % (
response.request.url, response), file=sys.stderr)
break
data = response.json()
for project in data['projects']:
# Skip forks
if not project['fullname'].startswith('forks/'):
yield project
yield project
url = data['pagination']['next']
@ -183,7 +182,7 @@ def get_project_ownership(tag, namespace):
project_branches_url = '{0}api/0/{1}/{2}/git/branches'.format(
PAGURE_URL, namespace, project['name'])
project_branches_rv = session.get(
project_branches_url, verify=VERIFY, timeout=30)
project_branches_url, verify=VERIFY, timeout=60)
# If the project's branches can't be reported, let's skip the project
# for now.
@ -193,17 +192,14 @@ def get_project_ownership(tag, namespace):
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_json['branches']:
# Although this is a list, Pagure only supports one owner for now
projects[project['name']] = project['access_users']['owner'][0]
if tag in project_branches_rv_json['branches'] or tag == 'f' + RAWHIDE:
yield project['name']
if tag == 'module-package-list' and not 'module-build-macros' in projects:
projects['module-build-macros'] = 'releng'
return projects
# This is a special project, not in dist-git, but which needs to be in the package list.
yield 'module-build-macros'
def set_koji_ownership(pkgs_to_ownership, arches):
def set_koji_ownership(packages, arches):
koji_options = get_options()
for arch in arches:
@ -231,23 +227,12 @@ def set_koji_ownership(pkgs_to_ownership, arches):
sys.exit(1)
koji_pkgs = {}
koji_users = [user['name'] for user in session.listUsers()]
for p in session.listPackages(tagID=tag, inherited=True):
koji_pkgs[p['package_name']] = p
for pkg in sorted(pkgs_to_ownership.keys()):
owner = pkgs[pkg]
if owner not in koji_users:
# add the user first
try:
session.createUser(owner)
except:
# user already exists
continue
koji_users.append(owner)
for pkg in packages:
owner = 'releng' # always
if pkg not in koji_pkgs:
extra_arches = None
if pkg in EXTRA_ARCH_LIST: