From 42cadc404ef6fd43a6302fcb4302987af3af5806 Mon Sep 17 00:00:00 2001
From: Aditya Bisoi <abisoi@redhat.com>
Date: Jun 16 2021 06:10:20 +0000
Subject: Remove deprecated arguments --dist and --module-name


JIRA: RHELCMP-4770
Signed-off-by: Aditya Bisoi <abisoi@redhat.com>

---

diff --git a/etc/bash_completion.d/rpkg.bash b/etc/bash_completion.d/rpkg.bash
index 18cdf47..c7f0880 100644
--- a/etc/bash_completion.d/rpkg.bash
+++ b/etc/bash_completion.d/rpkg.bash
@@ -33,7 +33,7 @@ _rpkg()
     # global options
 
     local options="--help -v -q"
-    local options_value="--dist --release --user --path"
+    local options_value="--release --user --path"
     local commands="build chain-build ci clean clog clone co container-build container-build-config commit compile copr-build diff flatpak-build \
     gimmespec giturl help gitbuildhash import install lint local mockbuild mock-config new new-sources patch prep pull push retire scratch-build sources \
     srpm switch-branch tag unused-patches upload verify-files verrel"
@@ -73,8 +73,6 @@ _rpkg()
             --config)
                 _filedir_exclude_paths
                 ;;
-            --dist)
-                ;;
             --user|-u)
                 ;;
             --path)
diff --git a/pyrpkg/__init__.py b/pyrpkg/__init__.py
index 8f10957..ca4b792 100644
--- a/pyrpkg/__init__.py
+++ b/pyrpkg/__init__.py
@@ -151,8 +151,6 @@ class Commands(object):
         self._localarch = None
         # A property to load the mock config
         self._mockconfig = None
-        # The name of the cloned repository
-        self._module_name = None
         # The dist git namespace
         self._ns = None
         # The package name from spec file
@@ -549,36 +547,6 @@ class Commands(object):
         """Set repository name"""
         self._repo_name = name
 
-    @property
-    def module_name(self):
-        """This property ensures the module attribute
-
-        .. deprecated:: 1.55
-           Use :meth:`repo_name` instead.
-        """
-        self.log.warning('Property module_name is deprecated. Please use '
-                         'repo_name instead.')
-        return self.repo_name
-
-    @module_name.setter
-    def module_name(self, module_name):
-        """Set module name
-
-        .. deprecated:: 1.55
-           Use :meth:`repo_name` instead.
-        """
-        self.log.warning('Property module_name is deprecated. Please use '
-                         'repo_name instead.')
-        self.repo_name = module_name
-
-    def load_module_name(self):
-        """Load repository name
-
-        .. deprecated:: 1.55
-           Use :meth:`load_repo_name` instead.
-        """
-        return self.load_repo_name()
-
     def load_repo_name(self):
         """Loads repository name
 
@@ -642,17 +610,6 @@ class Commands(object):
             self.log.warning('Failed to get ns from Git url or pushurl')
 
     @property
-    def ns_module_name(self):
-        """Return repository name
-
-        .. deprecated:: 1.55
-           Use :meth:`ns_repo_name` instead.
-        """
-        self.log.warning('Property ns_module_name is deprecated. Please use '
-                         'ns_repo_name instead.')
-        return self.ns_repo_name
-
-    @property
     def ns_repo_name(self):
         """Return repository name with namespace
 
diff --git a/pyrpkg/cli.py b/pyrpkg/cli.py
index 0f114da..19b9356 100644
--- a/pyrpkg/cli.py
+++ b/pyrpkg/cli.py
@@ -32,7 +32,6 @@ from six.moves import configparser
 import koji_cli.lib
 import pyrpkg.utils as utils
 from pyrpkg import Modulemd
-from pyrpkg import log as rpkgLogger
 from pyrpkg import rpkgError
 
 # argcomplete might not be available for all products which
@@ -43,22 +42,6 @@ except ImportError:
     argcomplete = None
 
 
-def warning_deprecated_dist(value):
-    """Warning deprecated of option dist"""
-    rpkgLogger.warning('Deprecation warning: --dist is deprecated and will be '
-                       'removed in future version. Use --release instead.')
-    return value
-
-
-def warning_deprecated_module_name(value):
-    """Warning deprecated of option --module-name"""
-    print('Deprecation warning: --module-name is deprecated and will be '
-          'removed in future version. Use combination of --name and '
-          '--namespace instead.',
-          file=sys.stderr)
-    return value
-
-
 # Adds `allow_abbrev' feature
 class _ArgumentParser(argparse.ArgumentParser):
     def __init__(self, *args, **kwargs):
@@ -274,7 +257,7 @@ class cliClient(object):
                                        kojiprofile,
                                        items['build_client'],
                                        user=self.args.user,
-                                       dist=self.args.dist or self.args.release,
+                                       dist=self.args.release,
                                        target=target,
                                        quiet=self.args.q,
                                        distgit_namespaced=dg_namespaced,
@@ -284,16 +267,6 @@ class cliClient(object):
                                        results_dir=results_dir
                                        )
 
-        if self.args.module_name:
-            # Repository name was specified via argument
-            if '/' not in self.args.module_name:
-                self._cmd.repo_name = self.args.module_name
-                if dg_namespaced:
-                    # No slash, assume rpms namespace
-                    self._cmd.ns = 'rpms'
-            else:
-                self._cmd.ns, self._cmd.repo_name = self.args.module_name.rsplit('/', 1)
-
         if self.args.repo_name:
             self._cmd.repo_name = self.args.repo_name
             if dg_namespaced and self.args.repo_namespace:
@@ -364,22 +337,6 @@ class cliClient(object):
                                 'dist macro. Generally, release is the name of a branch '
                                 'created in your package repository. --release is an alias '
                                 'of --dist, hence --release should be used instead.')
-        # Allow forcing the dist value
-        group.add_argument('--dist',
-                           default=None,
-                           type=warning_deprecated_dist,
-                           help='Deprecated. Use --release instead. You can use --dist '
-                                'for a while for backward-compatibility. It will be disabled'
-                                ' in future version.')
-        # Allow forcing the package name
-        self.parser.add_argument(
-            '--module-name',
-            type=warning_deprecated_module_name,
-            help='Deprecated. Use combination of --name and --namespace. '
-                 'Override the module name. Otherwise it is discovered from: '
-                 'Git push URL or Git URL (last part of path with .git '
-                 'extension removed) or from name macro in spec file. In that '
-                 'order.')
         self.parser.add_argument(
             '--name',
             metavar='NAME',
@@ -2771,14 +2728,6 @@ class cliClient(object):
             self.parser.print_help()
             sys.exit(1)
 
-        if self.args.module_name and self.args.repo_name:
-            self.parser.error(
-                'argument --name: not allowed with --module-name')
-
-        if self.args.module_name and self.args.repo_namespace:
-            self.parser.error(
-                'argument --namespace: not allowed with --module-name')
-
         if not self.args.repo_name and self.args.repo_namespace:
             self.parser.error(
                 'missing --name: using --namespace requires --name option')
diff --git a/tests/test_cli.py b/tests/test_cli.py
index 66144f7..1ccffe5 100644
--- a/tests/test_cli.py
+++ b/tests/test_cli.py
@@ -109,46 +109,6 @@ class CliTestCase(CommandTestCase):
         return abs_filename
 
 
-class TestModuleNameOption(CliTestCase):
-
-    create_repo_per_test = False
-
-    def setUp(self):
-        super(TestModuleNameOption, self).setUp()
-        self.conf_file = self.get_absolute_conf_filename('rpkg-ns.conf')
-
-    def get_cmd(self, repo_name, cfg=None):
-        cmd = ['rpkg', '--path', self.cloned_repo_path, '--module-name', repo_name, 'verrel']
-        with patch('sys.argv', new=cmd):
-            cli = self.new_cli(cfg=cfg)
-        return cli.cmd
-
-    def test_non_namespaced(self):
-        cmd = self.get_cmd('foo')
-        self.assertEqual(cmd._repo_name, 'foo')
-        self.assertEqual(cmd.ns_repo_name, 'foo')
-
-    def test_just_module_name(self):
-        cmd = self.get_cmd('foo', self.conf_file)
-        self.assertEqual(cmd._repo_name, 'foo')
-        self.assertEqual(cmd.ns_repo_name, 'rpms/foo')
-
-    def test_explicit_default(self):
-        cmd = self.get_cmd('rpms/foo', self.conf_file)
-        self.assertEqual(cmd._repo_name, 'foo')
-        self.assertEqual(cmd.ns_repo_name, 'rpms/foo')
-
-    def test_with_namespace(self):
-        cmd = self.get_cmd('container/foo', self.conf_file)
-        self.assertEqual(cmd._repo_name, 'foo')
-        self.assertEqual(cmd.ns_repo_name, 'container/foo')
-
-    def test_with_nested_namespace(self):
-        cmd = self.get_cmd('user/project/foo', self.conf_file)
-        self.assertEqual(cmd._repo_name, 'foo')
-        self.assertEqual(cmd.ns_repo_name, 'user/project/foo')
-
-
 class TestContainerBuildWithKoji(CliTestCase):
     """Test container_build with koji"""
 
@@ -3263,26 +3223,6 @@ class TestOptionNameAndNamespace(CliTestCase):
     create_repo_per_test = False
 
     @patch('sys.stderr', new_callable=six.StringIO)
-    def test_name_exclusive_with_module_name(self, stderr):
-        cli = [
-            'rpkg', '--module-name', 'somepkg', '--name', 'somepkg',
-            'request-repo'
-        ]
-        with patch('sys.argv', new=cli):
-            with self.assertRaises(SystemExit):
-                self.new_cli()
-
-    @patch('sys.stderr', new_callable=six.StringIO)
-    def test_namespace_exclusive_with_module_name(self, stderr):
-        cli = [
-            'rpkg', '--module-name', 'somepkg', '--namespace', 'modules',
-            'request-repo'
-        ]
-        with patch('sys.argv', new=cli):
-            with self.assertRaises(SystemExit):
-                self.new_cli()
-
-    @patch('sys.stderr', new_callable=six.StringIO)
     def test_namespace_not_in_configured_distgit_namespaces(self, stderr):
         conf_file = self.get_absolute_conf_filename(
             'rpkg-has-distgit-namespaces.conf')
@@ -3314,7 +3254,7 @@ class TestOptionNameAndNamespace(CliTestCase):
         ]
         with patch('sys.argv', new=cli):
             cli = self.new_cli()
-            self.assertEqual('somepkg', cli.cmd.module_name)
+            self.assertEqual('somepkg', cli.cmd.repo_name)
             self.assertEqual('rpms', cli.cmd.ns)
 
     def test_name_and_namespace_with_distgit_namespace_disabled(self):
diff --git a/tests/test_retire.py b/tests/test_retire.py
index d621ec4..a1605c3 100644
--- a/tests/test_retire.py
+++ b/tests/test_retire.py
@@ -93,13 +93,13 @@ class TestPackageRetirement(RetireTestCase):
         super(TestPackageRetirement, self).tearDown()
 
     def test_package_retire_with_namespace_disallowed(self):
-        args = ['rpkg', '--dist=master', 'retire', 'my reason']
+        args = ['rpkg', '--release=master', 'retire', 'my reason']
         client = self.new_client('rpms/rpkg', args)
         # retirement of packages is disabled by default
         self.assertRaises(rpkgError, client.retire)
 
     def test_package_retire_with_namespace_allowed(self):
-        args = ['rpkg', '--dist=master', 'retire', 'my reason']
+        args = ['rpkg', '--release=master', 'retire', 'my reason']
         client = self.new_client('rpms/rpkg', args)
         # un-block retirement of packages
         client.cmd.block_retire_ns.remove('rpms')
@@ -109,13 +109,13 @@ class TestPackageRetirement(RetireTestCase):
         self.assertEqual(len(client.cmd.push.call_args_list), 1)
 
     def test_package_retire_without_namespace_disallowed(self):
-        args = ['rpkg', '--dist=master', 'retire', 'my reason']
+        args = ['rpkg', '--release=master', 'retire', 'my reason']
         client = self.new_client('rpkg', args)
         # retirement of packages is disabled by default
         self.assertRaises(rpkgError, client.retire)
 
     def test_package_retire_without_namespace_allowed(self):
-        args = ['rpkg', '--dist=master', 'retire', 'my reason']
+        args = ['rpkg', '--release=master', 'retire', 'my reason']
         client = self.new_client('rpkg', args)
         # un-block retirement of packages
         client.cmd.block_retire_ns.remove('rpms')
@@ -145,7 +145,7 @@ class TestModuleRetirement(RetireTestCase):
         super(TestModuleRetirement, self).tearDown()
 
     def test_module_retire_with_namespace_allowed(self):
-        args = ['rpkg', '--dist=master', 'retire', 'my reason']
+        args = ['rpkg', '--release=master', 'retire', 'my reason']
         client = self.new_client('modules/rpkg', args)
         # retirement of modules is enabled by default
         client.retire()
@@ -154,7 +154,7 @@ class TestModuleRetirement(RetireTestCase):
         self.assertEqual(len(client.cmd.push.call_args_list), 1)
 
     def test_module_retire_with_namespace_disallowed(self):
-        args = ['rpkg', '--dist=master', 'retire', 'my reason']
+        args = ['rpkg', '--release=master', 'retire', 'my reason']
         client = self.new_client('modules/rpkg', args)
         # block retirement of modules
         client.cmd.block_retire_ns.append('modules')

