Closed thomashoneyman closed 1 year ago
As far as testing goes, beyond the unit tests I've also run the registry importer and verified that the import statistics are unchanged. This code change does not appear to affect the behavior of the registry.
💪 I'll let this sit for a day or two so that @f-f can take a look since it affects his Spago stuff.
Thanks @thomashoneyman, great work! 👏
This PR implements the
Version
andRange
types described in the spec (#533). The change is almost entirely mechanical; move over the data types, parser, and printer, and implement a JSON codec. However, I've made some decisions that I think notably improve how we use these types.First,
Version
andRange
are implemented in their own modules instead of sharing a module. This means that we no longer have to disambiguate version and range operations within the namespace, such asVersion.parseVersion
andVersion.parseRange
. It also means that range-specific operations get their own namespace (no moreVersion.union
orVersion.intersect
, which doesn't make any sense since those are range operations).Second, there is no longer a
ParseMode
usable with these types; instead, the registry only uses strict versions and ranges, and the application offers its ownLenientVersion
andLenientRange
types. This is an improvement for a lot of reasons!Manifest
) -- but right now it's up to developer discipline to not accidentally useVersion.parseVersion Version.Lenient
somewhere only strict versions should be allowed. A dedicatedLenientVersion
means you definitely expect to be dealing with non-strict versions, which is a big heads-up that this is a place to be careful in the code.Range.union
makes no sense in the lenient context; you no longer have one "input" you parsed from. And there are places where we useVersion.rawVersion
to indicate we want to print a raw version, but it could only ever have been possible to have a strict version (ie.Version.printVersion == Version.rawVersion
); this is confusing, because either we did want a raw version, in which case this could be a bug, or we didn't, in which caserawVersion
should not have been used.It's much nicer to just separate these concerns altogether, and so I've done just that. But I've kept all the same tests and ensured they all continue to pass.