Skip to content

Commit

Permalink
Add a hint to history info without trans IDs when no match found
Browse files Browse the repository at this point in the history
When the default value of the transaction ID argument is only `last`
users searching for transactions with specific packages might be confused
why the output is empty.

For example:
```
$ dnf5 history info --contains-pkgs=htop
```
Would search only the last transaction. On the other hand `list` works as
expected:
```
$ dnf5 history list --contains-pkgs=htop
```
It searches all transactions becuase the default for `list` is all
transactions.
  • Loading branch information
kontura committed Jan 10, 2025
1 parent 9cfa03d commit 0e73f49
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions dnf5/commands/history/history_info.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,17 @@ void HistoryInfoCommand::run() {
std::sort(transactions.begin(), transactions.end());
}

for (auto ts : transactions) {
libdnf5::cli::output::print_transaction_info(ts);
std::cout << std::endl;
if (!transactions.empty()) {
for (auto ts : transactions) {
libdnf5::cli::output::print_transaction_info(ts);
std::cout << std::endl;
}
} else {
if (ts_specs.empty()) {
std::cout << _("No match found, history info defaults to considering only the last transaction, specify "
"\"1..last\" range to search all transactions.")
<< std::endl;
}
}
}

Expand Down

0 comments on commit 0e73f49

Please sign in to comment.