rpmlint/rpmlint-2.1.0-fix-rpmlintrc-load-from-cmdline-v3.patch
2021-09-17 10:15:26 -04:00

62 lines
3.3 KiB
Diff

diff -up rpmlint-2.1.0/rpmlint/cli.py.fix-rpmlintrc-load-from-cmdline rpmlint-2.1.0/rpmlint/cli.py
--- rpmlint-2.1.0/rpmlint/cli.py.fix-rpmlintrc-load-from-cmdline 2021-09-17 10:07:00.599255215 -0400
+++ rpmlint-2.1.0/rpmlint/cli.py 2021-09-17 10:08:29.337741059 -0400
@@ -83,7 +83,7 @@ def process_lint_args(argv):
parser.add_argument('-V', '--version', action='version', version=__version__, help='show package version and exit')
parser.add_argument('-c', '--config', type=_validate_conf_location, help='load up additional configuration data from specified path (file or directory with *.toml files)')
parser.add_argument('-e', '--explain', nargs='+', default='', help='provide detailed explanation for one specific message id')
- parser.add_argument('-r', '--rpmlintrc', type=Path, help='load up specified rpmlintrc file')
+ parser.add_argument('-r', '--rpmlintrc', type=_is_file_path, help='load up specified rpmlintrc file')
parser.add_argument('-v', '--verbose', '--info', action='store_true', help='provide detailed explanations where available')
parser.add_argument('-p', '--print-config', action='store_true', help='print the settings that are in effect when using the rpmlint')
parser.add_argument('-i', '--installed', nargs='+', default='', help='installed packages to be validated by rpmlint')
@@ -164,6 +164,13 @@ def _validate_conf_location(string):
return config_paths
+def _is_file_path(path):
+ p = Path(path)
+ if not p.is_file():
+ raise argparse.ArgumentTypeError(f'{path} is not a valid file path')
+ return p
+
+
def lint():
"""
Main wrapper for lint command processing
diff -up rpmlint-2.1.0/rpmlint/lint.py.fix-rpmlintrc-load-from-cmdline rpmlint-2.1.0/rpmlint/lint.py
--- rpmlint-2.1.0/rpmlint/lint.py.fix-rpmlintrc-load-from-cmdline 2021-08-17 09:31:56.000000000 -0400
+++ rpmlint-2.1.0/rpmlint/lint.py 2021-09-17 10:11:13.989642586 -0400
@@ -35,6 +35,9 @@ class Lint(object):
self.profile.enable()
else:
self.profile = None
+
+ if options['rpmlintrc']:
+ options['rpmlintrc'] = [options['rpmlintrc']]
self._load_rpmlintrc()
if options['verbose']:
self.config.info = options['verbose']
@@ -161,6 +164,9 @@ class Lint(object):
Load rpmlintrc from argument or load up from folder
"""
if self.options['rpmlintrc']:
+ # Right now, we allow loading of just a single file, but the 'opensuse'
+ # branch contains auto-loading mechanism that can eventually load
+ # multiple files.
for rcfile in self.options['rpmlintrc']:
self.config.load_rpmlintrc(rcfile)
else:
diff -up rpmlint-2.1.0/test/test_lint.py.fix-rpmlintrc-load-from-cmdline rpmlint-2.1.0/test/test_lint.py
--- rpmlint-2.1.0/test/test_lint.py.fix-rpmlintrc-load-from-cmdline 2021-08-17 09:31:56.000000000 -0400
+++ rpmlint-2.1.0/test/test_lint.py 2021-09-17 10:06:40.937147554 -0400
@@ -410,7 +410,7 @@ def test_run_rpmlintrc_multiple(capsys,
def test_run_rpmlintrc_single_file(capsys, packages):
additional_options = {
'rpmfile': [packages],
- 'rpmlintrc': [TEST_RPMLINTRC]
+ 'rpmlintrc': TEST_RPMLINTRC
}
options = {**options_preset, **additional_options}
linter = Lint(options)