Skip to content

Commit 0da3bdb

Browse files
authored
Fix missing comparison for equal versions (#415)
2 parents f93e20f + 5fb428b commit 0da3bdb

File tree

3 files changed

+11
-36
lines changed

3 files changed

+11
-36
lines changed

RELEASE_NOTES.md

Lines changed: 2 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,11 @@
11
# Frequenz Repository Configuration Release Notes
22

3-
## Summary
4-
5-
<!-- Here goes a general summary of what this release is about -->
6-
7-
## Upgrading
8-
9-
<!-- Here goes notes on how to upgrade from previous versions, including deprecations and what they should be replaced with -->
10-
11-
### Cookiecutter template
12-
13-
All upgrading should be done via the migration script or regenerating the templates.
14-
15-
```bash
16-
curl -sSL https://raw.githubusercontent.com/frequenz-floss/frequenz-repo-config-python/v0.12/cookiecutter/migrate.py | python3
17-
```
18-
19-
But you might still need to adapt your code:
20-
21-
<!-- Here upgrade steps for cookiecutter specifically -->
22-
23-
## New Features
24-
25-
<!-- Here goes the main new features and examples or instructions on how to use them -->
26-
27-
### Cookiecutter template
28-
29-
<!-- Here new features for cookiecutter specifically -->
30-
313
## Bug Fixes
324

335
- Fixed some typos in the docs.
6+
- Fixed wrong comparison for `mike` versions when versions were equal.
7+
- Fixed version regex escaping of `.`. This means that a version like v0x1e1 were accepted as valid semver versions. Now this version is not considered a semver version anymore.
348
- `setuptools.grpc_tools`: Fix wrong passing of include paths when passed via:
359

3610
* Command-line: Now extra white-spaces and empty strings are removed, before they were passed to `protoc -I`.
3711
* `pyproject.toml`: Now an empty array/list can be passed to override the default paths, before this resulted in an empty string being passed to `protoc -I`.
38-
39-
### Cookiecutter template
40-
41-
<!-- Here bug fixes for cookiecutter specifically -->

src/frequenz/repo/config/mkdocs/mike.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -136,10 +136,10 @@ def build_mike_version(repo_info: RepoVersionInfo) -> MikeVersionInfo:
136136
)
137137

138138

139-
_is_version_re = re.compile(r"^v(\d+).(\d+)(-dev|-pre)?$")
140-
_stable_to_semver_re = re.compile(r"^v(\d+).(\d+)$")
141-
_pre_to_semver_re = re.compile(r"^v(\d+).(\d+)-pre$")
142-
_dev_to_semver_re = re.compile(r"^v(\d+).(\d+)-dev$")
139+
_is_version_re = re.compile(r"^v(\d+)\.(\d+)(?:-dev|-pre)?$")
140+
_stable_to_semver_re = re.compile(r"^v(\d+)\.(\d+)$")
141+
_pre_to_semver_re = re.compile(r"^v(\d+)\.(\d+)-pre$")
142+
_dev_to_semver_re = re.compile(r"^v(\d+)\.(\d+)-dev$")
143143

144144

145145
def _to_fake_sortable_semver(version: str) -> str:
@@ -207,6 +207,9 @@ def compare_mike_version(version1: str, version2: str) -> int:
207207
if is_version_v2: # version1 is not a version
208208
return 1
209209

210+
if version1 == version2:
211+
return 0
212+
210213
return -1 if version1 < version2 else 1
211214

212215

tests/mkdocs/test_mike.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,8 @@ def test_build_mike_version(
266266
("v2.0-pre", "v1.0-pre", 1),
267267
("v2.0", "v1.0-pre", 1),
268268
("blah", "v1.0-dev", 1),
269+
("blah", "blah", 0),
270+
("v1x0-dev", "v1.0-dev", 1),
269271
("alpha", "beta", -1),
270272
],
271273
)

0 commit comments

Comments
 (0)