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

Add global version_comparator #1919

Open
wants to merge 3 commits into
base: v2
Choose a base branch
from
Open

Conversation

n1ght-hunter
Copy link

This pr allows you do set a version_comparator when building the plugin that will get applied to all subsequent calls.
this does not change overriding if you call the builder manually but allows a way to alter version_comparator for js command calls

@n1ght-hunter n1ght-hunter requested a review from a team as a code owner October 11, 2024 09:21
Copy link
Contributor

Package Changes Through a40fbb2

There are 8 changes which include dialog with patch, dialog-js with patch, positioner with patch, positioner-js with patch, http with patch, http-js with patch, shell with patch, shell-js with patch

Planned Package Versions

The following package releases are the planned based on the context of changes in this pull request.

package current next
api-example 2.0.2 2.0.3
api-example-js 2.0.0 2.0.1
dialog 2.0.1 2.0.2
dialog-js 2.0.0 2.0.1
http 2.0.1 2.0.2
http-js 2.0.0 2.0.1
positioner 2.0.1 2.0.2
positioner-js 2.0.0 2.0.1
shell 2.0.1 2.0.2
shell-js 2.0.0 2.0.1

Add another change file through the GitHub UI by following this link.


Read about change files or the docs at github.com/jbolda/covector

Comment on lines +227 to +230
pub(crate) fn global_version_comparator(mut self, f: GlobalVersionComparator) -> Self {
self.global_version_comparator.replace(f);
self
}
Copy link
Member

Choose a reason for hiding this comment

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

this is the same as version_comparator method, no need to add a new one

Copy link
Author

Choose a reason for hiding this comment

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

its not this one is in a Arc not a box. if you are fine with change the normal one to an Arc then alot of the boiler plate can be removed

Copy link
Member

Choose a reason for hiding this comment

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

why does it have to be Arc?


pub struct UpdaterBuilder {
app_name: String,
current_version: Version,
config: Config,
version_comparator: Option<Box<dyn Fn(Version, RemoteRelease) -> bool + Send + Sync>>,
global_version_comparator: Option<GlobalVersionComparator>,
Copy link
Member

Choose a reason for hiding this comment

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

no need to add a new field either

@@ -93,12 +93,14 @@ impl RemoteRelease {
}

pub type OnBeforeExit = Arc<dyn Fn() + Send + Sync + 'static>;
pub(crate) type GlobalVersionComparator = Arc<dyn Fn(Version, RemoteRelease) -> bool + Send + Sync>;
Copy link
Member

Choose a reason for hiding this comment

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

and this type can also be removed

@@ -88,6 +93,10 @@ impl<R: Runtime, T: Manager<R>> UpdaterExt<R> for T {
builder = builder.current_exe_args(args);
}

if let Some(version_comparator) = version_comparator {
builder = builder.global_version_comparator(version_comparator.clone());
Copy link
Member

Choose a reason for hiding this comment

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

and then we can just call version_comparator here instead of global_version_comparator

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants