-
Notifications
You must be signed in to change notification settings - Fork 63
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
feat: add strict channel priority option #385
feat: add strict channel priority option #385
Conversation
if strict_channel_priority { | ||
if let Some(url) = found_in_channel.clone() { | ||
if repo_data.channel.base_url != url { | ||
continue; | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be done much shorter:
if strict_channel_priority { | |
if let Some(url) = found_in_channel.clone() { | |
if repo_data.channel.base_url != url { | |
continue; | |
} | |
} | |
} | |
if found_in_channel.map_or(false, |c| c != &repo_data.channel.base_url) { | |
continue; | |
} |
You dont need to check the strict_channel_priority
because the found_in_channel
is only set if that is true.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is much better!
if strict_channel_priority && !records.is_empty() { | ||
found_in_channel = Some(repo_data.channel.base_url.clone()); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just store a reference to forgo a clone:
if strict_channel_priority && !records.is_empty() { | |
found_in_channel = Some(repo_data.channel.base_url.clone()); | |
} | |
if strict_channel_priority && !records.is_empty() { | |
found_in_channel = Some(&repo_data.channel.base_url); | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!
Co-authored-by: Bas Zalmstra <zalmstra.bas@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Skips options for a package in other channels if it is already found in channels that are defined first.