Bug 1763991: Implement move-file update-action r=jewilde

Differential Revision: https://phabricator.services.mozilla.com/D143629
This commit is contained in:
Tom Ritter 2022-04-15 18:17:40 +00:00
parent 1f6c848ef2
commit cac3a77d97
2 changed files with 13 additions and 2 deletions

View File

@ -236,6 +236,7 @@ vendoring:
# Actions to take after updating. Applied in order.
# The action subfield is required. It must be one of:
# - copy-file
# - move-file
# - move-dir
# - replace-in-file
# - replace-in-file-regex
@ -243,7 +244,7 @@ vendoring:
# - run-script
# Unless otherwise noted, all subfields of action are required.
#
# If the action is copy-file or move-dir:
# If the action is copy-file, move-file, or move-dir:
# from is the source file
# to is the destination
#
@ -444,6 +445,7 @@ def _schema_1():
Required("action"): In(
[
"copy-file",
"move-file",
"move-dir",
"replace-in-file",
"replace-in-file-regex",
@ -563,7 +565,7 @@ class UpdateActions(object):
for v in values:
if "action" not in v:
raise Invalid("All file-update entries must specify a valid action")
if v["action"] in ["copy-file", "move-dir"]:
if v["action"] in ["copy-file", "move-file", "movie-dir"]:
if "from" not in v or "to" not in v or len(v.keys()) != 3:
raise Invalid(
"%s action must (only) specify 'from' and 'to' keys"

View File

@ -403,6 +403,15 @@ class VendorManifest(MozbuildObject):
contents = f.read()
with open(dst, "w") as f:
f.write(contents)
elif update["action"] == "move-file":
src = self.get_full_path(update["from"])
dst = self.get_full_path(update["to"])
self.logInfo(
{"s": src, "d": dst}, "action: move-file src: {s} dst: {d}"
)
shutil.move(src, dst)
elif update["action"] == "move-dir":
src = self.get_full_path(update["from"])
dst = self.get_full_path(update["to"])