#242 Add argument name and option --namespace to request-repo
Merged 5 years ago by cqi. Opened 5 years ago by cqi.

@@ -14,6 +14,7 @@ 

    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/

@@ -14,6 +14,7 @@ 

    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/

file modified
+27 -6
@@ -114,24 +114,42 @@ 

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

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

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

  

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

  

      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,

file modified
+22 -24
@@ -244,7 +244,7 @@ 

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

          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 = (

Fixes #200 #193

Signed-off-by: Chenxiong Qi cqi@redhat.com

Is re necessary here? self.config.get(self.name, 'distgit_namespaces').split() should do the same (even without strip I think).

No other remarkables found.

rebased onto f49b556

5 years ago

Pretty please pagure-ci rebuild

Is re necessary here? self.config.get(self.name, 'distgit_namespaces').split() should do the same (even without strip I think).

re is not necessary here. Fixed. Thanks!

Pull-Request has been merged by cqi

5 years ago