From 7892a83de5de962e530e5e8616e56c94c486d053 Mon Sep 17 00:00:00 2001 From: Brian Bouterse Date: Mon, 29 Aug 2022 15:16:02 -0400 Subject: [PATCH] Add workaround for .dev version parsing not semver The strings Pulp uses, e.g. `3.17.2.dev` is not semver parsable, which causes the semver tools to fail. See https://github.com/pulp/plugin_template/issues/682 for more info. This should only be needed in the 'dev' site since Pulp code will only every submit data with `.dev` at the end to the dev site. --- pulpanalytics/management/commands/summarize.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pulpanalytics/management/commands/summarize.py b/pulpanalytics/management/commands/summarize.py index 6777d0b..6ee4d8a 100644 --- a/pulpanalytics/management/commands/summarize.py +++ b/pulpanalytics/management/commands/summarize.py @@ -71,7 +71,11 @@ def _handle_components(systems, summary): xyz_dict = defaultdict(int) for component in components_qs.filter(name=name): - semver_version = semver.parse(component.version) + try: + semver_version = semver.parse(component.version) + except ValueError: # Pulp uses x.y.z.dev which is not semver compatible + component.version = component.version.replace('.dev', '-dev') + semver_version = semver.parse(component.version) xy_version = f"{semver_version['major']}.{semver_version['minor']}" xy_dict[xy_version] += 1 xyz_dict[component.version] +=1