Skip to content

Commit a2358d6

Browse files
committed
scan: fix unknown checkset during initial config load
The config load is performed in multiple stages: 1. parse `--config` path 2. load bundled config 3. load user & system configs 4. parse cmd args (needed for repo and targets) 5. load repo's config 6. parse full cmd args The problem is that the checkset is parsed during stage 4, which means it hasn't loaded the repo's config yet. While a more correct solution would be to parse only needed args during stage 4, it wasn't simple since the targets collect everything, including cmd args. So instead this just patches temporarily to not fail upon unknown checksets. Resolves: #576 Signed-off-by: Arthur Zamarin <arthurzam@gentoo.org>
1 parent 02b6032 commit a2358d6

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

src/pkgcheck/scripts/pkgcheck_scan.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import os
33
import shlex
44
from contextlib import ExitStack
5+
from unittest.mock import patch
56

67
from pkgcore import const as pkgcore_const
78
from pkgcore.repository import errors as repo_errors
@@ -370,7 +371,8 @@ def _setup_scan(parser, namespace, args):
370371
# have to be parsed twice, will probably require a custom snakeoil
371372
# arghparse method.
372373
# parse command line args to override config defaults
373-
namespace, _ = parser._parse_known_args(args, namespace)
374+
with patch("pkgcheck.scripts.argparse_actions.ChecksetArgs.__call__", lambda *a, **k: None):
375+
namespace, _ = parser._parse_known_args(args, namespace)
374376

375377
# Get the current working directory for repo detection and restriction
376378
# creation, fallback to the root dir if it's be removed out from under us.

0 commit comments

Comments
 (0)