From 84ee2d62a9aaa82465f7616bca5182938408be0d Mon Sep 17 00:00:00 2001 From: Dominik Rumian Date: Mar 09 2022 08:28:42 +0000 Subject: Fix: 'lint -i/--info' does not work 'lint' subcommand internally uses 'rpmlint'. 'rpmlint' version 2.X has changed some of its arguments, one of which is '-i'. Rpkg recognizes the installed version of 'rpmlint' and internally adjusts the input arguments accordingly so the functionality remains unchanged. Jira: RHELCMP-8506 Resolves: rhbz#2016616 Signed-off-by: Dominik Rumian --- diff --git a/pyrpkg/__init__.py b/pyrpkg/__init__.py index 85970df..fe3aa07 100644 --- a/pyrpkg/__init__.py +++ b/pyrpkg/__init__.py @@ -2692,6 +2692,7 @@ class Commands(object): cmd = ['rpmlint'] user_config_file_switch = '-f' # switch that uses rpmlint version 1.x + info_switch = '-i' # switch that uses rpmlint version 1.x # get rpmlint version installed in the system ret, stdout, _ = self._run_command(cmd + ['--version'], return_stdout=True, @@ -2701,11 +2702,12 @@ class Commands(object): if res is not None: if res.groups()[0] == '2': user_config_file_switch = '-r' + info_switch = '--info' self.log.debug('rpmlint version 2.x detected') default_rpmlintconf = '{0}.rpmlintrc'.format(self.repo_name) if info: - cmd.extend(['-i']) + cmd.extend([info_switch]) if rpmlintconf: cmd.extend([user_config_file_switch, os.path.join(self.path, rpmlintconf)]) elif os.path.isfile(os.path.join(self.path, default_rpmlintconf)): diff --git a/tests/test_cli.py b/tests/test_cli.py index dd21a54..b99b1dd 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -1103,6 +1103,23 @@ class TestLint(CliTestCase): ]) @patch('pyrpkg.Commands._run_command') + def test_lint_warning_with_info_newer_lint_package(self, _run_command): + self.checkout_branch(git.Repo(self.cloned_repo_path), 'eng-rhel-7') + + cli_cmd = ['rpkg', '--name', 'docpkg', '--path', self.cloned_repo_path, + 'lint', '--info'] + _run_command.return_value = [0, "version 2.0", None] + + with patch('sys.argv', new=cli_cmd): + cli = self.new_cli() + cli.lint() + + _run_command.assert_has_calls([ + call(['rpmlint', '--version'], return_stdout=True, return_text=True), + call(['rpmlint', '--info', os.path.join(cli.cmd.path, cli.cmd.spec)], shell=True), + ]) + + @patch('pyrpkg.Commands._run_command') def test_lint_with_default_config_file(self, _run_command): self.checkout_branch(git.Repo(self.cloned_repo_path), 'eng-rhel-7')