Skip to content

Commit d4d1bf9

Browse files
committed
Also check that MinimumVersion is a string
1 parent fa355d4 commit d4d1bf9

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

pre_commit_hooks/check_autopkg_recipes.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,8 @@ def validate_endofcheckphase(process, filename):
169169

170170

171171
def validate_minimumversion(process, min_vers, ignore_min_vers_before, filename):
172-
"""Ensure MinimumVersion is set appropriately for the processors used."""
172+
"""Ensure MinimumVersion is a string and is set appropriately for the
173+
processors used."""
173174

174175
# Processors for which a minimum version of AutoPkg is required.
175176
# Note: packaging.version.Version considers this True: "1.0" == "1.0.0"
@@ -210,13 +211,20 @@ def validate_minimumversion(process, min_vers, ignore_min_vers_before, filename)
210211
}
211212

212213
passed = True
214+
215+
# Validate that the MinimumVersion value is a string
216+
if not isinstance(min_vers, str):
217+
print(f"{filename}: MinimumVersion should be a string.")
218+
passed = False
219+
220+
# Validate that the MinimumVersion value fits the processors used
213221
for proc in [
214222
x
215223
for x in proc_min_versions
216224
if Version(proc_min_versions[x]) >= Version(ignore_min_vers_before)
217225
]:
218226
if proc in [x.get("Processor") for x in process]:
219-
if Version(min_vers) < Version(proc_min_versions[proc]):
227+
if Version(str(min_vers)) < Version(proc_min_versions[proc]):
220228
print(
221229
f"{filename}: {proc} processor requires minimum AutoPkg version {proc_min_versions[proc]}"
222230
)

0 commit comments

Comments
 (0)