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

Community Marketplace open-ended version range #4523

Open
Nadahar opened this issue Dec 27, 2024 · 1 comment
Open

Community Marketplace open-ended version range #4523

Nadahar opened this issue Dec 27, 2024 · 1 comment
Labels
enhancement An enhancement or new feature of the Core

Comments

@Nadahar
Copy link

Nadahar commented Dec 27, 2024

I find the current practice of always having to specify a compatibility end a bit strange. Since there's often no good reason to expect that something will stop working at a future version, the current "convention" seems to be to specify the next major version.

This means that now that main has changed to 5.0.0-SNAPSHOT pretty much all add-ons with a version range are now hidden - and in reality, the vast majority are likely to work just fine with 5.0.0. This means that a lot of Community Marketplace entries will have to be edited, or they will disappear from future versions. I think the upper bound only makes sense when there's a known reason why it would stop working.

Thus, I'm proposing to change the logic to accept an open-ended range in the form [x.x.x(.x)?;) or[x.x.x(.x)?;].

The change necessary is small, but as I can't submit a PR, I'll just have to make a suggestion here:

 .../java/org/openhab/core/addon/marketplace/BundleVersion.java     | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/bundles/org.openhab.core.addon.marketplace/src/main/java/org/openhab/core/addon/marketplace/BundleVersion.java b/bundles/org.openhab.core.addon.marketplace/src/main/java/org/openhab/core/addon/marketplace/BundleVersion.java
index ee01b7b51..c9ac47a28 100644
--- a/bundles/org.openhab.core.addon.marketplace/src/main/java/org/openhab/core/addon/marketplace/BundleVersion.java
+++ b/bundles/org.openhab.core.addon.marketplace/src/main/java/org/openhab/core/addon/marketplace/BundleVersion.java
@@ -29,7 +29,7 @@ public class BundleVersion {
     private static final Pattern VERSION_PATTERN = Pattern.compile(
             "(?<major>\\d+)\\.(?<minor>\\d+)\\.(?<micro>\\d+)(\\.((?<rc>RC)|(?<milestone>M))?(?<qualifier>\\d+))?");
     public static final Pattern RANGE_PATTERN = Pattern.compile(
-            "\\[(?<start>\\d+\\.\\d+(?<startmicro>\\.\\d+(\\.\\w+)?)?);(?<end>\\d+\\.\\d+(?<endmicro>\\.\\d+(\\.\\w+)?)?)(?<endtype>[)\\]])");
+            "\\[(?<start>\\d+\\.\\d+(?<startmicro>\\.\\d+(\\.\\w+)?)?);(?<end>\\d+\\.\\d+(?<endmicro>\\.\\d+(\\.\\w+)?)?)?(?<endtype>[)\\]])");
 
     private final String version;
     private final int major;
@@ -87,7 +87,10 @@ public class BundleVersion {
             return false;
         }
 
-        String endString = matcher.group("endmicro") != null ? matcher.group("end") : matcher.group("stop") + ".0";
+        if (matcher.group("end") == null) {
+            return true;
+        }
+        String endString = matcher.group("endmicro") != null ? matcher.group("end") : matcher.group("end") + ".0";
         boolean inclusive = "]".equals(matcher.group("endtype"));
         BundleVersion endVersion = new BundleVersion(endString);
         int comparison = this.compareTo(endVersion);

I've tested the above code, and it seems to work just fine.

Please note that there's also a bug fix here, since matcher.group("stop") throws an exception it that code is ever reached, since there's no stop group defined RANGE_PATTERN. I'm pretty sure it should be end instead of stop.

@Nadahar Nadahar added the enhancement An enhancement or new feature of the Core label Dec 27, 2024
@openhab-bot
Copy link
Collaborator

This issue has been mentioned on openHAB Community. There might be relevant details there:

https://community.openhab.org/t/millheat-local-api-development-questions/160139/146

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement An enhancement or new feature of the Core
Projects
None yet
Development

No branches or pull requests

2 participants