PR#4286: Adjust download-build messages

Merges #4286
https://pagure.io/koji/pull-request/4286

Fixes: #4283
https://pagure.io/koji/issue/4283
koji download-build doesn't work for scratch build?
This commit is contained in:
Tomas Kopecek 2025-01-06 10:00:21 +01:00
commit aa54d705bc
3 changed files with 19 additions and 7 deletions

View file

@ -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] <n-v-r | build_id | package>"
"[download] Download a completed build"
usage = "usage: %prog download-build [options] <n-v-r|build_id>"
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)")
@ -6849,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:

View file

@ -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

View file

@ -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] <n-v-r | build_id | package>
self.error_format = """Usage: %s download-build [options] <n-v-r|build_id>
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}
@ -187,7 +190,9 @@ class TestDownloadBuild(utils.CliTestCase):
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
@ -274,7 +279,10 @@ class TestDownloadBuild(utils.CliTestCase):
def test_handle_add_volume_help(self):
self.assert_help(
anon_handle_download_build,
"""Usage: %s download-build [options] <n-v-r | build_id | package>
"""Usage: %s download-build [options] <n-v-r|build_id>
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: