Bug 1785139: Try the shorthash when running ./mach vendor on a rust create r=jewilde

Differential Revision: https://phabricator.services.mozilla.com/D154827
This commit is contained in:
Tom Ritter 2022-08-18 14:19:35 +00:00
Родитель d61f881532
Коммит 696b99e059
1 изменённых файлов: 11 добавлений и 4 удалений

Просмотреть файл

@ -39,12 +39,15 @@ def _replace_in_file(file, pattern, replacement, regex=False):
contents = f.read()
if regex:
contents = re.sub(pattern, replacement, contents)
newcontents = re.sub(pattern, replacement, contents)
else:
contents = contents.replace(pattern, replacement)
newcontents = contents.replace(pattern, replacement)
if newcontents == contents:
raise Exception("Could not find %s in %s to replace with %s" % (pattern, file, replacement))
with open(file, "w") as f:
f.write(contents)
f.write(newcontents)
class VendorManifest(MozbuildObject):
@ -132,7 +135,11 @@ class VendorManifest(MozbuildObject):
):
# First update the Cargo.toml
cargo_file = os.path.join(os.path.dirname(self.yaml_file), "Cargo.toml")
_replace_in_file(cargo_file, old_revision, new_revision)
try:
_replace_in_file(cargo_file, old_revision, new_revision)
except:
# If we can't find it the first time, try again with a short hash
_replace_in_file(cargo_file, old_revision[:8], new_revision)
# Then call ./mach vendor rust
from mozbuild.vendor.vendor_rust import VendorRust