Skip to content

Commit

Permalink
Make history info without trans ID more user friendly and dnf4 comp…
Browse files Browse the repository at this point in the history
…atible

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
```
Searches all transactions becuase the default for `list` is all
transactions.

This adds additional logic to use the `last` transaction only if
`--contains-pkgs` is empty.
  • Loading branch information
kontura committed Jan 3, 2025
1 parent 9cfa03d commit b0e70bc
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion dnf5/commands/history/history_info.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,11 @@ void HistoryInfoCommand::run() {
std::vector<libdnf5::transaction::Transaction> transactions;

if (ts_specs.empty()) {
transactions = list_transactions_from_specs(history, {"last"});
if (contains_pkgs->get_value().empty()) {
transactions = list_transactions_from_specs(history, {"last"});
} else {
transactions = history.list_all_transactions();
}
} else {
transactions = list_transactions_from_specs(history, ts_specs);
}
Expand Down

0 comments on commit b0e70bc

Please sign in to comment.