From 661a5cb3e867eae2fc11d29a2a4083e8038043f5 Mon Sep 17 00:00:00 2001 From: Mike McLean Date: Jan 03 2025 20:37:54 +0000 Subject: [PATCH 1/4] adjust usage for download-build command --- diff --git a/cli/koji_cli/commands.py b/cli/koji_cli/commands.py index 562aae5..81c53a4 100644 --- a/cli/koji_cli/commands.py +++ b/cli/koji_cli/commands.py @@ -6814,8 +6814,10 @@ def handle_unblock_pkg(goptions, session, args): def anon_handle_download_build(options, session, args): - "[download] Download a built package" - usage = "usage: %prog download-build [options] " + "[download] Download a completed build" + usage = "usage: %prog download-build [options] " + usage += "\n\nDownloads files from the specified build entry" + usage += "\nNote: scratch builds do not have build entries. Use download-task for those" parser = OptionParser(usage=get_usage_str(usage)) parser.add_option("--arch", "-a", dest="arches", metavar="ARCH", action="append", default=[], help="Only download packages for this arch (may be used multiple times)") From e4ada43912ebb492fdab249c3fcb09362c1560ff Mon Sep 17 00:00:00 2001 From: Mike McLean Date: Jan 03 2025 20:44:07 +0000 Subject: [PATCH 2/4] unit test --- diff --git a/tests/test_cli/data/list-commands.txt b/tests/test_cli/data/list-commands.txt index ef70eb5..38041dd 100644 --- a/tests/test_cli/data/list-commands.txt +++ b/tests/test_cli/data/list-commands.txt @@ -91,7 +91,7 @@ build commands: wrapper-rpm Build wrapper rpms for any archives associated with a build. download commands: - download-build Download a built package + download-build Download a completed build download-logs Download logs for task download-task Download the output of a build task diff --git a/tests/test_cli/test_download_build.py b/tests/test_cli/test_download_build.py index e8fb19d..3e07462 100644 --- a/tests/test_cli/test_download_build.py +++ b/tests/test_cli/test_download_build.py @@ -18,7 +18,10 @@ class TestDownloadBuild(utils.CliTestCase): self.options.debug = False self.session = mock.MagicMock() self.session.getAPIVersion.return_value = koji.API_VERSION - self.error_format = """Usage: %s download-build [options] + self.error_format = """Usage: %s download-build [options] + +Downloads files from the specified build entry +Note: scratch builds do not have build entries. Use download-task for those (Specify the --help global option for a list of other help options) %s: error: {message} @@ -274,7 +277,10 @@ class TestDownloadBuild(utils.CliTestCase): def test_handle_add_volume_help(self): self.assert_help( anon_handle_download_build, - """Usage: %s download-build [options] + """Usage: %s download-build [options] + +Downloads files from the specified build entry +Note: scratch builds do not have build entries. Use download-task for those (Specify the --help global option for a list of other help options) Options: From a4fa9595f540b1e86f35b159f7666791c6a23789 Mon Sep 17 00:00:00 2001 From: Mike McLean Date: Jan 03 2025 20:48:28 +0000 Subject: [PATCH 3/4] tweak error message --- diff --git a/cli/koji_cli/commands.py b/cli/koji_cli/commands.py index 81c53a4..29b6e0a 100644 --- a/cli/koji_cli/commands.py +++ b/cli/koji_cli/commands.py @@ -6851,7 +6851,9 @@ def anon_handle_download_build(options, session, args): if suboptions.task_id: builds = session.listBuilds(taskID=build) if not builds: - error("No associated builds for task %s" % build) + error("No associated builds for task %s" + "\nIf this is a scratch build, try using download-task instead" + % build) build = builds[0]['build_id'] if suboptions.latestfrom: From dc023a3eb1cad4c4d160306a2f4faf486cc0d6a0 Mon Sep 17 00:00:00 2001 From: Mike McLean Date: Jan 03 2025 20:51:17 +0000 Subject: [PATCH 4/4] unit test --- diff --git a/tests/test_cli/test_download_build.py b/tests/test_cli/test_download_build.py index 3e07462..4c90aa9 100644 --- a/tests/test_cli/test_download_build.py +++ b/tests/test_cli/test_download_build.py @@ -190,7 +190,9 @@ Note: scratch builds do not have build entries. Use download-task for those self.options, self.session, ['--task-id', build_id], - stderr='No associated builds for task %s\n' % build_id, + stderr='No associated builds for task %s\n' + 'If this is a scratch build, try using download-task instead\n' + % build_id, stdout='', activate_session=None, exit_code=1