Skip to contentSkip to conversation

fetch2/crate: skip yanked versions when reading cargo index

PATCH New [email protected] 1 participant 1 message May 7

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fetch2/crate: skip yanked versions when reading cargo index

From: Thomas Perrot <[email protected]>

The cargo sparse index marks yanked crate versions with "yanked": true. Treat those the same way as non-existing versions so that version checking never promotes a yanked release as the latest one.

---
 lib/bb/fetch2/crate.py | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
lib/bb/fetch2/crate.py +2 -1
index b89817ab94d5..d84bae0bcd1e 100644
@@ -178,7 +178,8 @@ class Crate(Wget):
         response = self._fetch_index(ud.versionsurl, ud, d)
         for line in response.splitlines():
             data = json.loads(line)
-            versions.append((0, data["vers"], ""))
+            if not data.get("yanked", False):
+                versions.append((0, data["vers"], ""))
 
         versions = sorted(versions, key=cmp_to_key(bb.utils.vercmp))
         return (versions[-1][1], "")
Signature · 1 line
2.54.0