Skip to content

Commit

Permalink
Added logic to support nuget versions suffix with numbers (#253)
Browse files Browse the repository at this point in the history
* Added logic to support nuget versions such as rc1/beta2

Co-authored-by: kuqin <[email protected]>
  • Loading branch information
kuqin12 and kuqin12 authored Jun 11, 2021
1 parent 0a9eb12 commit e7cb9c9
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
3 changes: 2 additions & 1 deletion .cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@
"Boothole",
"dbxupdate",
"FileFlagsMask",
"markdownlint"
"markdownlint",
"xffd"
]
}
12 changes: 11 additions & 1 deletion edk2toolext/environment/extdeptypes/nuget_dependency.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,17 @@ def normalize_version(version):

int_parts = tuple([0 if a == "" else int(a) for a in parts])

if tag not in [None, "beta", "alpha", "rc"]:
if tag is not None:
# It might start with "beta*", "alpha*" or "rc*"
legit_tag = False
for rv in ["beta", "alpha", "rc"]:
if tag.startswith(rv):
legit_tag = True
else:
# Otherwise, it is legit
legit_tag = True

if not legit_tag:
raise ValueError(f"Unparsable version tag: {tag}")

if len(int_parts) > 4:
Expand Down
3 changes: 3 additions & 0 deletions edk2toolext/tests/test_nuget_dependency.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,9 @@ def test_normalize_version(self):
version5 = "3.2.1.-alpha"
proper_version5 = "3.2.1-alpha"
self.assertEqual(proper_version5, NugetDependency.normalize_version(version5))
version6 = "3.2.1.0-rc1"
proper_version6 = "3.2.1-rc1"
self.assertEqual(proper_version6, NugetDependency.normalize_version(version6))
# try some bad cases
with self.assertRaises(ValueError):
NugetDependency.normalize_version("not a number")
Expand Down

0 comments on commit e7cb9c9

Please sign in to comment.