From d4a61c69d0cf8ab48544f9c04997fc6359a5eebe Mon Sep 17 00:00:00 2001
From: Tomas Kopecek <tkopecek@redhat.com>
Date: Apr 08 2019 07:49:08 +0000
Subject: block_pkglist compatibility fix


On older hubs --force is not supported, so CLI will fail on unknown
parameter. This use force option only if it is explicitly required.

Fixes: https://pagure.io/koji/issue/1388

---

diff --git a/cli/koji_cli/commands.py b/cli/koji_cli/commands.py
index 900b8eb..1704d1a 100644
--- a/cli/koji_cli/commands.py
+++ b/cli/koji_cli/commands.py
@@ -388,7 +388,12 @@ def handle_block_pkg(goptions, session, args):
         return ret
     session.multicall = True
     for package in args[1:]:
-        session.packageListBlock(tag, package, force=options.force)
+        # force is not supported on older hub, so use it only explicitly
+        # https://pagure.io/koji/issue/1388
+        if options.force:
+            session.packageListBlock(tag, package, force=options.force)
+        else:
+            session.packageListBlock(tag, package)
     session.multiCall(strict=True)
 
 
diff --git a/tests/test_cli/test_block_pkg.py b/tests/test_cli/test_block_pkg.py
index 5e8d4b2..1af6ff9 100644
--- a/tests/test_cli/test_block_pkg.py
+++ b/tests/test_cli/test_block_pkg.py
@@ -82,9 +82,9 @@ class TestBlockPkg(unittest.TestCase):
             session.mock_calls, [
                 call.getTag(tag),
                 call.listPackages(tagID=dsttag['id'], inherited=True),
-                call.packageListBlock(tag, packages[0], force=False),
-                call.packageListBlock(tag, packages[1], force=False),
-                call.packageListBlock(tag, packages[2], force=False),
+                call.packageListBlock(tag, packages[0]),
+                call.packageListBlock(tag, packages[1]),
+                call.packageListBlock(tag, packages[2]),
                 call.multiCall(strict=True)])
         self.assertNotEqual(rv, 1)
 

