Skip to content

Commit 87e1204

Browse files
committed
Canonicalize 'vX.Y.Z' BD versions when comparing and searching
The Black Duck Knowledgebase is sometimes inconsistent (even within a single component) with whether the version names have a leading "v". eg, simdutf has versions 3.2.14 and v3.2.13. Add logic to the existing canonicalize_version() function to strip a leading "v" so comparisons aren't thrown off by this. Change-Id: Id46e15433a8d864332d9d67543403615730fcf91 Reviewed-on: https://review.couchbase.org/c/build-tools/+/194025 Tested-by: Chris Hillery <[email protected]> Reviewed-by: Ming Ho <[email protected]>
1 parent 4523583 commit 87e1204

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

blackduck/jenkins/detect-scan/update-manual-manifest

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ class UpdateComponents:
2222
match the manifests.
2323
"""
2424

25+
# Match a version number that starts with a "v" followed by a digit.
26+
v_re = re.compile(r"^v[0-9]")
27+
2528
# There are two important data structures in this class: comp_map and manifest.
2629
# comp_map represents the current state in Black Duck (when the program is
2730
# first run), while manifest represents the desired state as specified by the
@@ -268,19 +271,16 @@ class UpdateComponents:
268271
canonicalize that version name. Normally this is just the
269272
version name unchanged, but Erlang and Golang have inconsistent
270273
version naming in the Knowledgebase which leads to false
271-
matches/misses.
274+
matches/misses. We also strip a leading "v" because a number
275+
of components in the Knowledgebase are inconsitent about this.
272276
"""
273277

274278
if component_name.startswith("erlang"):
275279
return version[4:] if version.startswith("OTP-") else version
276280
elif component_name.startswith("go programming language"):
277281
return version[2:] if version.startswith("go") else version
278-
elif component_name in ("folly", "spdlog"):
279-
# Quite a few components an have inconsistent "v" at the
280-
# beginning. It might be worth making it a general
281-
# canonicalization to strip that, but for now just listing a
282-
# couple components we know have caused trouble.
283-
return version[1:] if version.startswith("v") else version
282+
elif self.v_re.search(version):
283+
return version[1:]
284284
else:
285285
return version
286286

@@ -361,6 +361,8 @@ class UpdateComponents:
361361
# Ensure one of those found versions is an exact match.
362362
ver_ok = False
363363
for ver_entry in versions:
364+
# Compare the canonicalized version name, in particular to handle
365+
# arbitrary "v" / non-"v" version names.
364366
version_name = self.canonicalize_version(
365367
component_name, ver_entry['versionName']
366368
)

0 commit comments

Comments
 (0)