Skip to content

Commit

Permalink
fix: reverse the filters order when grep (#4332)
Browse files Browse the repository at this point in the history
- this is to avoid the first keyword from starting with a dash ('-')
- see RHINENG-15287

Signed-off-by: Xiangce Liu <[email protected]>
(cherry picked from commit d1065f5)
  • Loading branch information
xiangce committed Jan 16, 2025
1 parent 61643f8 commit dcd738c
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions insights/core/spec_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ def __init__(self, relative_path, root="/", save_as=None, ds=None, ctx=None, cle
if self.ds and filters.ENABLED
else False
)
self._filters = filters.get_filters(self.ds, True) if self.ds else set()
self._filters = filters.get_filters(self.ds, True) if self.ds else dict()

self.validate()

Expand Down Expand Up @@ -267,7 +267,9 @@ def create_args(self):
args = []
if self._filters:
log.debug("Pre-filtering %s", self.relative_path)
args.append(["grep", "-F", "\n".join(self._filters), self.path])
args.append(
["grep", "-F", "\n".join(sorted(self._filters.keys(), reverse=True)), self.path]
)

return args

Expand Down Expand Up @@ -361,7 +363,7 @@ def __init__(
if self.ds and filters.ENABLED
else False
)
self._filters = filters.get_filters(self.ds, True) if self.ds else set()
self._filters = filters.get_filters(self.ds, True) if self.ds else dict()

self.validate()

Expand Down Expand Up @@ -389,7 +391,7 @@ def create_args(self):

if self.split and self._filters:
log.debug("Pre-filtering %s", self.relative_path)
command.append(["grep", "-F", "\n".join(self._filters)])
command.append(["grep", "-F", "\n".join(sorted(self._filters.keys(), reverse=True))])

return command

Expand Down

0 comments on commit dcd738c

Please sign in to comment.