From f49b556dad692c9ab285472834dda10418c1fdae Mon Sep 17 00:00:00 2001 From: Chenxiong Qi Date: Jul 11 2018 02:06:57 +0000 Subject: Add argument name and option --namespace to request-repo Fixes #200 #193 Signed-off-by: Chenxiong Qi --- diff --git a/conf/etc/rpkg/fedpkg-stage.conf b/conf/etc/rpkg/fedpkg-stage.conf index 37033cb..7d0400c 100644 --- a/conf/etc/rpkg/fedpkg-stage.conf +++ b/conf/etc/rpkg/fedpkg-stage.conf @@ -14,6 +14,7 @@ clone_config = bz.default-component %(repo)s sendemail.to %(repo)s-owner@fedoraproject.org distgit_namespaced = True +distgit_namespaces = rpms container modules lookaside_namespaced = True kerberos_realms = STG.FEDORAPROJECT.ORG oidc_id_provider = https://id.stg.fedoraproject.org/openidc/ diff --git a/conf/etc/rpkg/fedpkg.conf b/conf/etc/rpkg/fedpkg.conf index 5079770..52c69fc 100644 --- a/conf/etc/rpkg/fedpkg.conf +++ b/conf/etc/rpkg/fedpkg.conf @@ -14,6 +14,7 @@ clone_config = bz.default-component %(repo)s sendemail.to %(repo)s-owner@fedoraproject.org distgit_namespaced = True +distgit_namespaces = rpms container modules lookaside_namespaced = True kerberos_realms = FEDORAPROJECT.ORG oidc_id_provider = https://id.fedoraproject.org/openidc/ diff --git a/fedpkg/cli.py b/fedpkg/cli.py index 6cd7c60..dd76a7c 100644 --- a/fedpkg/cli.py +++ b/fedpkg/cli.py @@ -114,24 +114,42 @@ user configuration located at ~/.config/rpkg/{0}.conf. For example: Below is a basic example of the command to request a dist-git repository for the package foo: - fedpkg --name foo request-repo 1234 + fedpkg request-repo name 1234 Request a module with namespace explicitly: - fedpkg --name foo --namespace modules request-repo + fedpkg --namespace modules request-repo foo '''.format(self.name, urlparse(self.config.get( '{0}.pagure'.format(self.name), 'url')).netloc) + dg_namespaced = self._get_bool_opt('distgit_namespaced') + if dg_namespaced and self.config.has_option( + self.name, 'distgit_namespaces'): + ns_choices = self.config.get( + self.name, 'distgit_namespaces').split() + else: + ns_choices = None + request_repo_parser = self.subparsers.add_parser( 'request-repo', formatter_class=argparse.RawDescriptionHelpFormatter, help=help_msg, description=description) request_repo_parser.add_argument( + 'name', + help='Repository name to request.') + request_repo_parser.add_argument( 'bug', nargs='?', type=int, help='Bugzilla bug ID of the package review request. ' 'Not required for requesting a module repository') request_repo_parser.add_argument( + '--namespace', + required=False, + default='rpms', + choices=ns_choices, + dest='new_repo_namespace', + help='Namespace of repository. If omitted, default to rpms.') + request_repo_parser.add_argument( '--description', '-d', help='The repo\'s description in dist-git') monitoring_choices = [ 'no-monitoring', 'monitoring', 'monitoring-with-scratch'] @@ -169,7 +187,7 @@ requesting a repository in the tests namespace. Below is a basic example of the command to request a dist-git repository for the space tests/foo: - fedpkg --name foo request-tests-repo "Description of the repository" + fedpkg request-tests-repo name "Description of the repository" Note that the space name needs to reflect the intent of the tests and will undergo a manual review. @@ -182,6 +200,9 @@ undergo a manual review. help=help_msg, description=description) request_tests_repo_parser.add_argument( + 'name', + help='Repository name to request.') + request_tests_repo_parser.add_argument( 'description', help='Description of the tests repository') request_tests_repo_parser.set_defaults(command=self.request_tests_repo) @@ -478,8 +499,8 @@ suggest_reboot=False def request_repo(self): self._request_repo( - repo_name=self.cmd.repo_name, - ns=self.cmd.ns, + repo_name=self.args.name, + ns=self.args.new_repo_namespace, branch='master', summary=self.args.summary, description=self.args.description, @@ -493,7 +514,7 @@ suggest_reboot=False def request_tests_repo(self): self._request_repo( - repo_name=self.cmd.repo_name, + repo_name=self.args.name, ns='tests', description=self.args.description, name=self.name, diff --git a/test/test_cli.py b/test/test_cli.py index d70ceb2..1ecefe2 100644 --- a/test/test_cli.py +++ b/test/test_cli.py @@ -244,7 +244,7 @@ class TestRequestRepo(CliTestCase): mock_request_post.return_value = mock_rv cli_cmd = ['fedpkg-stage', '--path', self.cloned_repo_path, - 'request-repo', '1441813'] + 'request-repo', 'testpkg', '1441813'] cli = self.get_cli(cli_cmd) cli.request_repo() @@ -281,7 +281,7 @@ class TestRequestRepo(CliTestCase): mock_request_post.return_value = mock_rv cli_cmd = ['fedpkg-stage', '--path', self.cloned_repo_path, - '--name', 'nethack', 'request-repo', '1441813'] + 'request-repo', 'nethack', '1441813'] cli = self.get_cli(cli_cmd) cli.request_repo() @@ -321,8 +321,7 @@ class TestRequestRepo(CliTestCase): mock_request_post.return_value = mock_rv cli_cmd = ['fedpkg-stage', '--path', self.cloned_repo_path, - '--name', 'nethack', '--namespace', 'modules', - 'request-repo'] + 'request-repo', '--namespace', 'modules', 'nethack'] cli = self.get_cli(cli_cmd) cli.request_repo() @@ -360,9 +359,10 @@ class TestRequestRepo(CliTestCase): mock_rv.json.return_value = {'issue': {'id': 2}} mock_request_post.return_value = mock_rv - cli_cmd = ['fedpkg-stage', '--path', self.cloned_repo_path, - '--name', 'nethack', '--namespace', 'container', - 'request-repo', '1441813'] + cli_cmd = [ + 'fedpkg-stage', '--path', self.cloned_repo_path, + 'request-repo', '--namespace', 'container', 'nethack', '1441813' + ] cli = self.get_cli(cli_cmd) cli.request_repo() @@ -401,7 +401,7 @@ class TestRequestRepo(CliTestCase): mock_request_post.return_value = mock_rv cli_cmd = ['fedpkg-stage', '--path', self.cloned_repo_path, - '--name', 'nethack', 'request-repo', '1441813', '-d', + 'request-repo', 'nethack', '1441813', '-d', 'a description', '-s', 'a summary', '-m', 'no-monitoring', '-u', 'http://test.local'] cli = self.get_cli(cli_cmd) @@ -439,7 +439,7 @@ class TestRequestRepo(CliTestCase): mock_request_post.return_value = mock_rv cli_cmd = ['fedpkg-stage', '--path', self.cloned_repo_path, - '--name', 'nethack', 'request-repo', '--exception'] + 'request-repo', '--exception', 'nethack'] cli = self.get_cli(cli_cmd) cli.request_repo() @@ -471,7 +471,7 @@ class TestRequestRepo(CliTestCase): """Tests request-repo errors when the package is wrong""" mock_bz.getbug.return_value = self.mock_bug cli_cmd = ['fedpkg-stage', '--path', self.cloned_repo_path, - '--name', 'not-nethack', 'request-repo', '1441813'] + 'request-repo', 'not-nethack', '1441813'] cli = self.get_cli(cli_cmd) expected_error = ('The package in the Bugzilla bug "nethack" doesn\'t ' 'match the one provided "not-nethack"') @@ -486,7 +486,7 @@ class TestRequestRepo(CliTestCase): self.mock_bug.product = 'Red Hat' mock_bz.getbug.return_value = self.mock_bug cli_cmd = ['fedpkg-stage', '--path', self.cloned_repo_path, - '--name', 'nethack', 'request-repo', '1441813'] + 'request-repo', 'nethack', '1441813'] cli = self.get_cli(cli_cmd) expected_error = \ 'The Bugzilla bug provided is not for "Fedora" or "Fedora EPEL"' @@ -501,7 +501,7 @@ class TestRequestRepo(CliTestCase): self.mock_bug.summary = 'I am so wrong' mock_bz.getbug.return_value = self.mock_bug cli_cmd = ['fedpkg-stage', '--path', self.cloned_repo_path, - '--name', 'nethack', 'request-repo', '1441813'] + 'request-repo', 'nethack', '1441813'] cli = self.get_cli(cli_cmd) expected_error = \ 'Invalid title for this Bugzilla bug (no ":" present)' @@ -516,7 +516,7 @@ class TestRequestRepo(CliTestCase): self.mock_bug.summary = 'So:Wrong' mock_bz.getbug.return_value = self.mock_bug cli_cmd = ['fedpkg-stage', '--path', self.cloned_repo_path, - '--name', 'nethack', 'request-repo', '1441813'] + 'request-repo', 'nethack', '1441813'] cli = self.get_cli(cli_cmd) expected_error = \ 'Invalid title for this Bugzilla bug (no "-" present)' @@ -531,7 +531,7 @@ class TestRequestRepo(CliTestCase): self.mock_bug.summary = ('Review Request: fedpkg - lorum ipsum') mock_bz.getbug.return_value = self.mock_bug cli_cmd = ['fedpkg-stage', '--path', self.cloned_repo_path, - '--name', 'nethack', 'request-repo', '1441813'] + 'request-repo', 'nethack', '1441813'] cli = self.get_cli(cli_cmd) expected_error = ('The package in the Bugzilla bug "fedpkg" doesn\'t ' 'match the one provided "nethack"') @@ -549,7 +549,7 @@ class TestRequestRepo(CliTestCase): '%Y%m%dT%H:%M:%S') mock_bz.getbug.return_value = self.mock_bug cli_cmd = ['fedpkg-stage', '--path', self.cloned_repo_path, - '--name', 'nethack', 'request-repo', '1441813'] + 'request-repo', 'nethack', '1441813'] cli = self.get_cli(cli_cmd) expected_error = \ 'The Bugzilla bug\'s review was approved over 60 days ago' @@ -564,7 +564,7 @@ class TestRequestRepo(CliTestCase): self.mock_bug.flags[0]['name'] = 'something else' mock_bz.getbug.return_value = self.mock_bug cli_cmd = ['fedpkg-stage', '--path', self.cloned_repo_path, - '--name', 'nethack', 'request-repo', '1441813'] + 'request-repo', 'nethack', '1441813'] cli = self.get_cli(cli_cmd) expected_error = 'The Bugzilla bug is not approved yet' try: @@ -578,7 +578,7 @@ class TestRequestRepo(CliTestCase): self.mock_bug.assigned_to = None mock_bz.getbug.return_value = self.mock_bug cli_cmd = ['fedpkg-stage', '--path', self.cloned_repo_path, - '--name', 'nethack', 'request-repo', '1441813'] + 'request-repo', 'nethack', '1441813'] cli = self.get_cli(cli_cmd) expected_error = 'The Bugzilla bug provided is not assigned to anyone' try: @@ -592,7 +592,7 @@ class TestRequestRepo(CliTestCase): self.mock_bug.product = 'Red Hat' mock_bz.getbug.return_value = self.mock_bug cli_cmd = ['fedpkg-stage', '--path', self.cloned_repo_path, - '--name', '$nethack', 'request-repo', '1441813'] + 'request-repo', '$nethack', '1441813'] cli = self.get_cli(cli_cmd) expected_error = ( 'The repository name "$nethack" is invalid. It must be at least ' @@ -610,7 +610,7 @@ class TestRequestRepo(CliTestCase): """Tests a standard request-repo call when the Pagure API call fails""" mock_bz.getbug.return_value = self.mock_bug cli_cmd = ['fedpkg-stage', '--path', self.cloned_repo_path, - '--name', 'nethack', 'request-repo', '1441813'] + 'request-repo', 'nethack', '1441813'] cli = self.get_cli(cli_cmd) mock_rv = Mock() mock_rv.ok = False @@ -629,7 +629,7 @@ class TestRequestRepo(CliTestCase): self.mock_bug.product = 'Red Hat' mock_bz.getbug.return_value = self.mock_bug cli_cmd = ['fedpkg-stage', '--path', self.cloned_repo_path, - '--name', 'nethack', 'request-repo'] + 'request-repo', 'nethack'] cli = self.get_cli(cli_cmd) expected_error = \ 'A Bugzilla bug is required on new repository requests' @@ -1110,8 +1110,7 @@ class TestRequestTestsRepo(CliTestCase): mock_request_post.return_value = mock_post_rv cli_cmd = ['fedpkg-stage', '--path', self.cloned_repo_path, - '--name', 'foo', 'request-tests-repo', - 'Some description'] + 'request-tests-repo', 'foo', 'Some description'] cli = self.get_cli(cli_cmd) cli.request_tests_repo() @@ -1143,8 +1142,7 @@ class TestRequestTestsRepo(CliTestCase): mock_request_get.return_value = mock_get_rv cli_cmd = ['fedpkg-stage', '--path', self.cloned_repo_path, - '--name', 'foo', 'request-tests-repo', - 'Some description'] + 'request-tests-repo', 'foo', 'Some description'] cli = self.get_cli(cli_cmd) expected_error = (