Skip to content

Commit

Permalink
Merge pull request #112 from craigcomstock/cfe-3905
Browse files Browse the repository at this point in the history
CFE-3905: Adjust version parsing to include dashes as well as periods
  • Loading branch information
craigcomstock authored May 5, 2022
2 parents 0043679 + ac464f3 commit af04850
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
6 changes: 4 additions & 2 deletions cfbs/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
in main.py for -h/--help/help.
"""
import os
import re
import logging as log
import json

Expand Down Expand Up @@ -438,11 +439,12 @@ def update_command():

if "version" in module:
local_ver = [
int(version_number) for version_number in module["version"].split(".")
int(version_number)
for version_number in re.split("[-\.]", module["version"])
]
index_ver = [
int(version_number)
for version_number in index_info["version"].split(".")
for version_number in re.split("[-\.]", index_info["version"])
]
if local_ver > index_ver:
print(
Expand Down
3 changes: 2 additions & 1 deletion cfbs/validate.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ def validate_version(name, modules):
raise CFBSIndexException(name, "Missing required attribute 'version'")
if type(modules[name]["version"]) != str:
raise CFBSIndexException(name, "'version' must be of type string")
regex = r"(0|[1-9][0-9]*).(0|[1-9][0-9]*).(0|[1-9][0-9]*)"
print("validating version {}".format(modules[name]["version"]))
regex = r"(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(-([0-9]+))?"
if re.fullmatch(regex, modules[name]["version"]) == None:
raise CFBSIndexException(name, "'version' must match regex %s" % regex)

Expand Down

0 comments on commit af04850

Please sign in to comment.