@@ -25,6 +25,9 @@ class UpdateComponents:
2525 # Match a version number that starts with a "v" followed by a digit.
2626 v_re = re .compile (r"^v[0-9]" )
2727
28+ # Match a version number that looks like a date
29+ date_re = re .compile (r"^([0-9]{4})\.([0-9]{1,2})\.([0-9]{1,2})$" )
30+
2831 # There are two important data structures in this class: comp_map and manifest.
2932 # comp_map represents the current state in Black Duck (when the program is
3033 # first run), while manifest represents the desired state as specified by the
@@ -269,20 +272,34 @@ class UpdateComponents:
269272 """
270273 Given a version name for a specified component name,
271274 canonicalize that version name. Normally this is just the
272- version name unchanged, but Erlang and Golang have inconsistent
275+ version name unchanged, but a few components have inconsistent
273276 version naming in the Knowledgebase which leads to false
274- matches/misses. We also strip a leading "v" because a number
275- of components in the Knowledgebase are inconsitent about this.
277+ matches/misses. We also strip a leading "v" because a number of
278+ components in the Knowledgebase are inconsistent about this.
276279 """
277280
281+ if self .v_re .search (version ):
282+ # Strip any leading "v" before any other possible heuristics
283+ version = version [1 :]
284+
278285 if component_name .startswith ("erlang" ):
286+ # Strip any leading "OTP-"
279287 return version [4 :] if version .startswith ("OTP-" ) else version
280- elif component_name .startswith ("go programming language" ):
288+ if component_name .startswith ("go programming language" ):
289+ # Strip any leading "go"
281290 return version [2 :] if version .startswith ("go" ) else version
282- elif self .v_re .search (version ):
283- return version [1 :]
284- else :
285- return version
291+ if "certifi" in component_name :
292+ match = self .date_re .match (version )
293+ if match :
294+ # Choose to have zero-padded month/day values, eg.
295+ # "2023.05.07" vs. "2023.5.7". Certifi seems to use
296+ # zero-padding; Conda tends to report those versions
297+ # without zero-padding; and Black Duck randomly has
298+ # one or the other.
299+ return f"{ match [1 ]:>04} .{ match [2 ]:>02} .{ match [3 ]:>02} "
300+
301+ return version
302+
286303
287304 def fallback_version_if_necessary (self , comp_name , comp_id , manifest_ver ):
288305 """
0 commit comments