Skip to content

Commit

Permalink
Fix up the version stripping code
Browse files Browse the repository at this point in the history
Summary: I thought this was being tested in CI. It wasn't. It failed in about a million ways. Oops!

Reviewed By: dtolnay

Differential Revision: D61874799

fbshipit-source-id: 954e2a8cd26624626cf8aa892d1942b7d83284c7
  • Loading branch information
ndmitchell authored and facebook-github-bot committed Aug 27, 2024
1 parent 96c044d commit 2dfccb8
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions shim/shims.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -401,24 +401,26 @@ def _fix_dep(x: str) -> [
def remove_version(x: str) -> str:
# When upgrading libraries we either suffix them as `-old` or with a version, e.g. `-1-08`
# Strip those so we grab the right one in open source.
if x.endswith("/md-5"): # md-5 is the one exception
if x.endswith(":md-5"): # md-5 is the one exception
return x
xs = x.split("-")
for i in range(len(xs)):
for i in reversed(range(len(xs))):
s = xs[i]
if s == "old" or isdigit(s):
if s == "old" or s.isdigit():
xs.pop(i)
else:
break
return xs.join("-")
return "-".join(xs)

if x == "//common/rust/shed/fbinit:fbinit":
return "fbsource//third-party/rust:fbinit"
elif x == "//common/rust/shed/sorted_vector_map:sorted_vector_map":
return "fbsource//third-party/rust:sorted_vector_map"
elif x == "//watchman/rust/watchman_client:watchman_client":
return "fbsource//third-party/rust:watchman_client"
elif x.startswith("fbsource//third-party/rust:") or x.startswith(":"):
elif x.startswith("fbsource//third-party/rust:"):
return remove_version(x)
elif x.startswith(":"):
return x
elif x.startswith("//buck2/facebook/"):
return None
Expand All @@ -431,9 +433,9 @@ def _fix_dep(x: str) -> [
elif x.startswith("fbcode//third-party-buck/platform010/build"):
return "shim//third-party" + x.removeprefix("fbcode//third-party-buck/platform010/build")
elif x.startswith("fbsource//third-party"):
return "shim//third-party" + remove_version(x.removeprefix("fbsource//third-party"))
return "shim//third-party" + x.removeprefix("fbsource//third-party")
elif x.startswith("third-party//"):
return "shim//third-party/" + remove_version(x.removeprefix("third-party//"))
return "shim//third-party/" + x.removeprefix("third-party//")
elif x.startswith("//folly"):
oss_depends_on_folly = read_config("oss_depends_on", "folly", False)
if oss_depends_on_folly:
Expand Down Expand Up @@ -471,4 +473,6 @@ def _assert_eq(x, y):
fail("Expected {} == {}".format(x, y))

def _test():
_assert_eq("fbsource//third-party/rust:derive_more-1", "shim//third-party/rust:derive_more")
_assert_eq(_fix_dep("fbsource//third-party/rust:derive_more-1"), "fbsource//third-party/rust:derive_more")

_test()

0 comments on commit 2dfccb8

Please sign in to comment.