-
-
Notifications
You must be signed in to change notification settings - Fork 346
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
Support reading BuildIDs #1645
Support reading BuildIDs #1645
Conversation
To solve #1545 I recommend adding a mapping for build |
Does that mean we would need to override every mod that has a ksp_version or ksp_version_max of 1.0.5, or will 1.0.5.1 fit that requirement? |
@politas yes, but should be batchable with @pjf regex-magick. Alternatively, we just let it be, ignore 1.0.5/1.0.5.1, and use the strategy for any such future occurrences. (I would be A-OK with this). The main issue in #1545 of warning users when they're not completely up-to-date is taken care of by Module Manager anyway, and I doubt there are very many users using mods that don't also have Module Manager installed. |
Sorry, ModuleManager? What? |
@NathanKell He means the warning that MM displays if you are on 1.0.5.1024 |
Interesting. Because in the last few days two people have had that issue despite having MM, so they must have been ignoring the warning. Ah well... :] |
Awesome, looking forward to this. =) |
So, the good news is that @NathanKell assures me that build IDs are unified across operating systems, so we shouldn't have to split on OS. Clearly whatever I was thinking there is either old or wrong. Also, because we're using Likewise, we can probably have a "1.1.0-beta" version, and have our I'm also hella jetlagged right now, but in any case having a mapping of builds to versions in the metadata is a great idea. |
|
||
private readonly IWin32Registry _registry; | ||
|
||
public KSPVersion this[string buildId] |
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.
Hey, that's really cool! I had no idea we could do this. :)
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.
Glancing at the code it looks sensible to me, but I haven't had a chance to test it yet. I do have some build IDs (all from Linux, but which I'm told will be the same everywhere):
I'm guessing this means that for build IDs we should strip leading zeros and/or just treat them as integers. |
@pjf Made some changes.
I like the idea of mapping {
"builds": {
"1028": "1.0.5.1028",
"1172": "1.1.0.1172",
"1174": "1.1.0.1174"
},
"short_versions": {
"1.0.5": "1.0.5.1028"
}
} Basically we consider a full KSP version to have four components: This screws up the existing short/long logic in |
I really think we should take this opportunity to switch to an external lookup table in the database. This would help future-proof major versions of CKAN as we update the client itself less often, not having the version info hardcoded would be good. It might even be good to move the script to determine where to look for the BuildID to the primary database to further future proof it. |
I wouldn't recommend treating them as integers either. Just use a string conversion lookup table. |
Added all the BuildIDs I have to https://github.com/KSP-CKAN/CKAN-meta/blob/master/builds.json |
@pjf included it in his comment on KSP-CKAN/CKAN#1645
I like this idea, sounds awesome 👍 |
5d5f3d8
to
17727db
Compare
Major update with version range goodness, see first post for details. |
Until Jenkins generates more open .version files @sarbian
9052adf
to
03144f9
Compare
26c3b80
to
647014e
Compare
Now with glorious 100% statement coverage on the new cases. |
@KSP-CKAN/wranglers I've been using the changes in this build as my daily driver for a few weeks now and haven't run into any issues, let me know if you want a build to test this out. |
If you link a full build I'll tinker with it. |
You know what the biggest issue with this is going to be? The standard advice for what people should do if they want to install mods that aren't compatible with their KSP version is to change the version in the Readme file. This change is going to break that method. |
Yes, now we'll have to tell them to change the extension of build.txt to build.txt.bak and then change versions in readme. |
Ok, that's less of a hassle than I was thinking. |
From my testing it does what is says on the tin. Falls back to readme if buildID.txt is missing or invalid. Tested a few different buildIDs and got the correct version each time. I've had a skim of the code and nothing glaring stands out. @plague006 @politas how'd your testing go? |
Been using it for testing PRs and whatnot and haven't run into any issues with it. |
I haven't tried it. |
I've had a really good read of this and really like the design. I can't see anything super obvious that should hold us back. Merging with thanks @dbent ! |
I'm catching up on PRs, and you are all amazing. Thank you! |
This catches and fixes corrupted version numbers in the form of `1.1.` that can still persist in registry files (like mine). Closes KSP-CKAN#1780, makes KSP-CKAN#1645 safer.
@pjf @politas @plague006 @Dazpoet @NathanKell
This PR allows CKAN to get more accurate KSP version information by reading
buildID.txt
. This requires the use of a mapping table to map BuildIDs to actual KSP versions. This mapping potentially exists in 3 locations:The basic process is:
buildID.txt
KspVersion
from anIBuildMap
.readme.txt
.In order to better support this functionality I've introduced two basic new classes:
KspVersion
andKspVersionRange
.KspVersion
is a replacement forKSPVersion
and is a dumber version of the latter. All it knows is that a KSP version can have four components: a major number, a minor number, a patch number, and a build number. Some of these components may be undefined in which case all less significant components must also be undefined. The following are validKspVersion
strings:""
(the empty string)"1"
"1.0"
"1.0.0"
"1.0.0.0"
Since some components may be undefined (like the first four examples listed above) a
KspVersion
can be converted to aKspVersionRange
. AKspVersionRange
represents twoKspVersion
objects (a lower and upper bound) which have fully defined components and boolean flags which indicate if those bounds are inclusive or exclusive.The previous examples have the following
KspVersionRange
(the range syntax is standard mathematical representation of a range with[
,]
representing inclusive bounds and(
,)
representing exclusive bounds, this also how nuget does it).KspVersion
KspVersionRange
""
"(,)"
"1"
"[1.0.0.0, 2.0.0.0)"
"1.0"
"[1.0.0.0, 1.1.0.0)"
"1.0.0"
"[1.0.0.0, 1.0.1.0)"
"1.0.0.0"
"[1.0.0.0, 1.0.0.0]"
This allows us to map BuildIDs like
1028
to version strings like1.0.5.1028
and have everything JustWork™. Because when a mod says it requires KSP"1.0.5"
it's really saying it requires the range"[1.0.5.0, 1.0.6.0)"
. So a mod could require specifically1.0.5.1028
and know it works only with that specific build.Another nice property of this is that if we fallback to the
readme.txt
and get a version string like"1.1.0"
that will automatically translate into the range"[1.1.0.0, 1.1.1.0)"
. If a mod targets"1.1.0"
it will work because"[1.1.0.0, 1.1.1.0)"
(game version range) is a subset of"[1.1.0.0, 1.1.1.0)"
(mod version range). However, if a mod targets a specific build, say"1.1.0.1196"
it will not work because"[1.1.0.0, 1.1.1.0)"
(game version range) is not a subset of"[1.1.0.1196, 1.1.0.1196]"
(mod version range).This also gets rid of the hacky-ness of converting "1.0" to "1.0.0" and "1.0.99".
Because this touches such a fundamental part of the client, it will require a lot of testing, but for now the code is in place.