Skip to content

Commit

Permalink
Fix behavior of repoquery-n command
Browse files Browse the repository at this point in the history
Commit de9643a (first shipped in dnf 4.2.8) changed opts.command
from a list to a simple string, but code in RepoQueryCommand still
handled it as if it was a list.

This broke silently because Python will iterate over a string character
by character, so it never produced a syntax error or an exception that
would be noticed.

But it broke behavior of the `repoquery-n` form, since it would no
longer detect that command to restrict search of packages.

Before this commit, this command would (incorrectly) succeed:
  $ dnf repoquery-n joe-4.6
  joe-0:4.6-6.fc31.x86_64

After this commit:
  $ dnf repoquery-n joe-4.6
  (empty)

This command still works as expected:
  $ dnf repoquery-n joe
  joe-0:4.6-6.fc31.x86_64

Closes: #1611
Approved by: m-blaha
  • Loading branch information
filbranden authored and rh-atomic-bot committed Apr 1, 2020
1 parent 3c10131 commit 1f00a5f
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions dnf/cli/commands/repoquery.py
Original file line number Diff line number Diff line change
Expand Up @@ -448,10 +448,8 @@ def run(self):
remote_packages = self._add_add_remote_packages()

kwark = {}
forms = [self.nevra_forms[command] for command in self.opts.command
if command in list(self.nevra_forms.keys())]
if forms:
kwark["forms"] = forms
if self.opts.command in self.nevra_forms:
kwark["forms"] = [self.nevra_forms[self.opts.command]]
pkgs = []
query_results = q.filter(empty=True)

Expand Down

0 comments on commit 1f00a5f

Please sign in to comment.