Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix and use ModuleProfile::is_default() method #988

Merged
merged 4 commits into from
Oct 27, 2023

Conversation

pkratoch
Copy link
Contributor

No description provided.

@j-mracek j-mracek self-assigned this Oct 26, 2023
const auto & modulemd_profile = static_cast<ModulemdProfile *>(g_ptr_array_index(profiles, i));
result_profiles.push_back(ModuleProfile(
modulemd_profile,
std::find(default_profiles.begin(), default_profiles.end(), modulemd_profile_get_name(modulemd_profile)) !=
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not wrong, but written code in that way might be less readable (this is a personal opinion).

std::find(default_profiles.begin(), default_profiles.end(), modulemd_profile_get_name(modulemd_profile)) !=
                default_profiles.end()));

It is possible to use temporal variable

bool is_default  = std::find(default_profiles.begin(), default_profiles.end(), modulemd_profile_get_name(modulemd_profile)) !=
                default_profiles.end()));

Copy link
Member

@pmatilai pmatilai Oct 27, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed, temporals are a simple yet powerful way to make complex conditions far more readable, even obvious.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, fixed.

The previously used `modulemd_profile_is_default` gets the information
about defaults from modulemd-packager yaml document, which is available
when building a module, but doesn't work for modules after building.
@j-mracek
Copy link
Contributor

LGTM

@j-mracek
Copy link
Contributor

@pkratoch May I ask you whether there is any blocker why CI tests for module list cannot be enabled dnf/module/list.feature?

@pkratoch
Copy link
Contributor Author

@pkratoch May I ask you whether there is any blocker why CI tests for module list cannot be enabled dnf/module/list.feature?

Oh, good point. I'll take a look at which tests could be enabled now.

@j-mracek j-mracek added this pull request to the merge queue Oct 27, 2023
Merged via the queue into rpm-software-management:main with commit 35c6491 Oct 27, 2023
7 checks passed
@pkratoch pkratoch deleted the profile-is-default branch November 9, 2023 12:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

3 participants