WebOfTrust / keripy

Key Event Receipt Infrastructure - the spec and implementation of the KERI protocol
https://keripy.readthedocs.io/en/latest/
Apache License 2.0
60 stars 55 forks source link

Semver comparison issues for migrations in same dev release set #820

Open iFergal opened 4 months ago

iFergal commented 4 months ago

Version

1.2.0-dev1 - 1.2.0-dev10

Environment

Mac OS, Python 3.12.2

Expected behavior

I think we should be able to check migrations on a higher dev tag for the same version.

Not sure if we would plan on consolidating migrations prior to the next patch release instead, but I'd imagine that might cause headaches in workflows if stakeholders are involved in using test environments that are persisted.

Actual behavior

This error is raised, despite dev4 being older.

keri.kering.ConfigurationError: Database version=1.2.0-dev4 is ahead of library version=1.2.0-dev10

The reason for this is the Semver library will compare dev4 and dev10 as strings lexographically, and consider 4 bigger than 1 (ignoring the 0).

>>> semver.compare('1.2.0-dev4', '1.2.0-dev10')
1
>>> semver.compare('1.2.1', '1.2.0')
1
>>> semver.compare('1.2.0-4', '1.2.0-10')
-1

If the build number is just an integer, it works as intended as 4 < 10.

I quite like having dev in the version, so maybe could call .replace('dev', '') before semver comparing?

Steps to reproduce