From 963ac125d1093a30552a205395a88b7803aeabba Mon Sep 17 00:00:00 2001 From: Michal Pospíšil Date: Nov 10 2025 14:24:21 +0000 Subject: Clone the API key info into all help messages I was looking at the help text for request-branch and completely overlooked the instruction to have a look at request-repo. To imporve this, I used a couple of strings and cloned the text into all affected commands. Also fixed some explicit fedpkg mentions with string interpolation in the parts I touched. Merges: https://pagure.io/fedpkg/pull-request/609 Signed-off-by: Michal Pospíšil --- diff --git a/fedpkg/cli.py b/fedpkg/cli.py index ac5cb53..e612155 100644 --- a/fedpkg/cli.py +++ b/fedpkg/cli.py @@ -302,15 +302,12 @@ class fedpkgClient(cliClient): else: return None - def register_request_repo(self): - help_msg = 'Request a new dist-git repository' + def _common_api_key_description(self): pagure_section = '{0}.pagure'.format(self.name) pagure_url = config_get_safely(self.config, pagure_section, 'url') pagure_url_parsed = urlparse(pagure_url).netloc - description = textwrap.dedent(''' - Request a new dist-git repository - + return ''' Before the operation, you need to generate a pagure.io API token at: https://{1}/settings/token/new @@ -318,14 +315,23 @@ class fedpkgClient(cliClient): "Create a new ticket" Update your token with the following command: - fedpkg set-pagure-token + {0} set-pagure-token - Command saves token to fedpkg config file: + Command saves token to {0} config file: ~/.config/rpkg/{0}.conf For example: [{0}.pagure] token = + '''.format(self.name, pagure_url_parsed) + + def register_request_repo(self): + help_msg = 'Request a new dist-git repository' + + description = textwrap.dedent(''' + Request a new dist-git repository + + {0} Below is a basic example of the command to request a dist-git repository for the package foo: @@ -345,7 +351,7 @@ class fedpkgClient(cliClient): fedpkg request-repo foo 1234 --monitor \\ --backend custom --upstreamurl "project's url" \\ --project-name bar - '''.format(self.name, pagure_url_parsed)) + '''.format(self._common_api_key_description())) request_repo_parser = self.subparsers.add_parser( 'request-repo', @@ -425,8 +431,7 @@ class fedpkgClient(cliClient): https://docs.fedoraproject.org/en-US/ci/share-test-code - Please refer to the request-repo command to see what has to be done before - requesting a repository in the tests namespace. + {2} Below is a basic example of the command to request a dist-git repository for the space tests/foo: @@ -435,7 +440,12 @@ class fedpkgClient(cliClient): Note that the space name needs to reflect the intent of the tests and will undergo a manual review. - '''.format(self.name, get_dist_git_url(anongiturl))) + '''.format( + self.name, + get_dist_git_url(anongiturl), + self._common_api_key_description(), + ) + ) request_tests_repo_parser = self.subparsers.add_parser( 'request-tests-repo', @@ -458,8 +468,7 @@ class fedpkgClient(cliClient): description = textwrap.dedent(''' Request a new dist-git branch - Please refer to the help of the request-repo command to see what has - to be done before requesting a dist-git branch. + {1} Branch name could be one of current active Fedora and EPEL releases. Use command ``{0} releases-info`` to get release names that can be used to request @@ -481,7 +490,7 @@ class fedpkgClient(cliClient): argument has to be before --sl argument, because --sl allows multiple values. {0} request-branch branch_name --sl bug_fixes:2020-06-01 rawhide:2019-12-01 - '''.format(self.name)) + '''.format(self.name, self._common_api_key_description())) request_branch_parser = self.subparsers.add_parser( 'request-branch', @@ -534,6 +543,8 @@ class fedpkgClient(cliClient): description = textwrap.dedent(""" Request an unretirement of the package branch + {1} + The branch name could be one of the current active Fedora and EPEL releases. Use the command ``{0} releases-info`` to get release names that can be used to request a branch. @@ -563,7 +574,7 @@ class fedpkgClient(cliClient): Request an unretirement outside package repository: {0} request-unretirement --repo name_of_package - """.format(self.name)) + """.format(self.name, self._common_api_key_description())) request_unretirement_parser = self.subparsers.add_parser( "request-unretirement", formatter_class=argparse.RawTextHelpFormatter,