README.md
May 30, 2026 ยท View on GitHub
This is now archived. I have moved to a simpler
vX.Y.(Z*1000+W)encoding scheme for the use cases described below.
This library implements a simple encoding and decoding scheme to combine two semver versions into one.
My intended use for this is as a versioning scheme for Hugo Modules that are wrappers of upstream libraries. The wrapper and the library have diverging release cycles, and we want to maintain the upstream version info, so we cannot just use the upstream version as is.
Features:
- The upstream library controls the major version.
- It should be easy to determine the upstream version just by looking at it.
- It should always be possible to programmatically decode back to the originals.
- A minor or patch increment from either of the two versions should result in a version that is greater than the previous version.
Encoding
The minor and patch fields are each encoded as:
- A leading digit (the width) telling how many digits each version number occupies.
- Then the two version numbers, each zero-padded to that width.
Some examples with a width of 2 digits per version:
v3.0.0 + v3.0.0 = v3.20000.20000v3.1.0 + v3.0.0 = v3.20100.20000v3.6.5 + v3.99.99 = v3.20699.20599
If either of the version numbers reaches 100, the width grows to 3:
v3.6.5 + v3.99.100 = v3.3006099.3005100