From 7ca4ceda16f84c362fa5156ce1167f6acdff1aff Mon Sep 17 00:00:00 2001 From: Mike McLean Date: Jul 28 2020 15:11:02 +0000 Subject: [PATCH 1/3] editTag: make compat perm_id option an alias for perm Fixes https://pagure.io/koji/issue/2375 --- diff --git a/hub/kojihub.py b/hub/kojihub.py index 9f67b85..fb4d887 100644 --- a/hub/kojihub.py +++ b/hub/kojihub.py @@ -3368,13 +3368,13 @@ def _edit_tag(tagInfo, **kwargs): raise koji.GenericError("Maven support not enabled") tag = get_tag(tagInfo, strict=True) + if 'perm' in kwargs and 'perm_id' not in kwargs: + # for compatibility, perm and perm_id are aliases + # if both are given, perm_id takes precedence + kwargs['perm_id'] = kwargs['perm'] if 'perm_id' in kwargs: - kwargs['perm_id'] = get_perm_id(kwargs['perm_id'], strict=True) - elif 'perm' in kwargs: - if kwargs['perm'] is None: - kwargs['perm_id'] = None - else: - kwargs['perm_id'] = get_perm_id(kwargs['perm'], strict=True) + if kwargs['perm_id'] is not None: + kwargs['perm_id'] = get_perm_id(kwargs['perm_id'], strict=True) name = kwargs.get('name') if name and tag['name'] != name: From 01b3dc8099ded083d9599e1ba24bf0718992e626 Mon Sep 17 00:00:00 2001 From: Mike McLean Date: Jul 28 2020 15:22:57 +0000 Subject: [PATCH 2/3] for editTag2, perm option is preferred over perm_id alias Versions 1.21 and 1.22 of kojihub will throw an error if perm_id=None is given For details see: https://pagure.io/koji/issue/2375 --- diff --git a/cli/koji_cli/commands.py b/cli/koji_cli/commands.py index 3eae261..bffd85c 100644 --- a/cli/koji_cli/commands.py +++ b/cli/koji_cli/commands.py @@ -5039,7 +5039,7 @@ def handle_edit_tag(goptions, session, args): if options.arches: opts['arches'] = koji.parse_arches(options.arches) if options.no_perm: - opts['perm_id'] = None + opts['perm'] = None elif options.perm: opts['perm'] = options.perm if options.unlock: From ef0c7ae5ea90070585cc4816bf4c17334e07fa69 Mon Sep 17 00:00:00 2001 From: Mike McLean Date: Jul 28 2020 15:30:30 +0000 Subject: [PATCH 3/3] fix unit test --- diff --git a/tests/test_cli/test_edit_tag.py b/tests/test_cli/test_edit_tag.py index 719dcbb..128bbab 100644 --- a/tests/test_cli/test_edit_tag.py +++ b/tests/test_cli/test_edit_tag.py @@ -75,7 +75,7 @@ class TestEditTag(utils.CliTestCase): args.append('--unlock') args.append('--no-maven-support') args.append('--no-include-all') - opts = {'perm_id': None, + opts = {'perm': None, 'locked': not locked, 'maven_support': not maven_support, 'maven_include_all': not maven_include_all}