Add lexicographic versioning scheme#160
Conversation
Signed-off-by: Kunz, Immanuel <immanuel.kunz@aisec.fraunhofer.de>
Signed-off-by: Kunz, Immanuel <immanuel.kunz@aisec.fraunhofer.de>
Signed-off-by: Kunz, Immanuel <immanuel.kunz@aisec.fraunhofer.de>
13e36ad to
9064438
Compare
| return remove_spaces(str(string)) | ||
|
|
||
| def __lt__(self, other): | ||
| return self.value.encode("utf-8") < other.value.encode("utf-8") |
There was a problem hiding this comment.
Is there some reference docs that explain how two UTF-8 byte strings are compared, so we can get that working beyond Python?
There was a problem hiding this comment.
It looks like this conforms with rfc 3629 which states
UTF-8 encodes UCS characters as a varying number of octets, where the number of octets, and the value of each, depend on the integer value assigned to the character in ISO/IEC 10646 (the character number, a.k.a. code position, code point or Unicode scalar value). This encoding form has the following characteristics (all values are in hexadecimal):
...
- The byte-value lexicographic sorting order of UTF-8 strings is the same as if ordered by character numbers. Of course this is of limited interest since a sort order based on character numbers is almost never culturally valid.
There was a problem hiding this comment.
thank you for checking!
There was a problem hiding this comment.
Np. Thank you for making the PR and following this through, it seems like a good general purpose version scheme to have available. 👍
pombredanne
left a comment
There was a problem hiding this comment.
Could you also consider using JSON tests in the same style as https://github.com/package-url/vers-spec/blob/main/tests/conan_version_cmp_test.json
|
It is now further specified here: package-url/vers-spec#37 |
|
Since package-url/vers-spec#37 is now merged, is this PR also good to merge @pombredanne ? |
darakian
left a comment
There was a problem hiding this comment.
for clarity I approve of adding this to the spec
|
@immqu Thank you ++ for carrying this through! |
This PR introduces a simple string versioning scheme that compares strings based on lexicographical order (UTF-8 encoded).
Addresses package-url/vers-spec#24