Bug 1637845 - Implement --check-for-update, controlling the output carefully for scripted use r=glob

Differential Revision: https://phabricator.services.mozilla.com/D76614
This commit is contained in:
Tom Ritter 2020-06-10 14:49:49 +00:00
Родитель 33e15a98a5
Коммит ccd8f7d35a
2 изменённых файлов: 18 добавлений и 7 удалений

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

@ -30,7 +30,12 @@ class Vendor(MachCommandBase):
category="misc", category="misc",
description="Vendor third-party dependencies into the source repository.", description="Vendor third-party dependencies into the source repository.",
) )
@CommandArgument("--check-for-update", action="store_true", default=False) @CommandArgument(
"--check-for-update",
action="store_true",
help="For scripted use, prints the new commit to update to, or nothing if up to date.",
default=False,
)
@CommandArgument( @CommandArgument(
"--ignore-modified", "--ignore-modified",
action="store_true", action="store_true",
@ -38,8 +43,12 @@ class Vendor(MachCommandBase):
default=False, default=False,
) )
@CommandArgument("-r", "--revision", help="Repository tag or commit to update to.") @CommandArgument("-r", "--revision", help="Repository tag or commit to update to.")
@CommandArgument("--verify", "-v", action="store_true", help="(Only) verify the manifest") @CommandArgument(
@CommandArgument("library", nargs=1, help="The moz.yaml file of the library to vendor.") "--verify", "-v", action="store_true", help="(Only) verify the manifest"
)
@CommandArgument(
"library", nargs=1, help="The moz.yaml file of the library to vendor."
)
def vendor( def vendor(
self, self,
library, library,
@ -59,6 +68,8 @@ class Vendor(MachCommandBase):
self.populate_logger() self.populate_logger()
self.log_manager.enable_unstructured() self.log_manager.enable_unstructured()
if check_for_update:
logging.disable()
try: try:
manifest = load_moz_yaml(library) manifest = load_moz_yaml(library)
@ -69,7 +80,7 @@ class Vendor(MachCommandBase):
print(e) print(e)
sys.exit(1) sys.exit(1)
if not ignore_modified: if not ignore_modified and not check_for_update:
self.check_modified_files() self.check_modified_files()
if not revision: if not revision:
revision = "master" revision = "master"
@ -104,7 +115,7 @@ Please commit or stash these changes before vendoring, or re-run with `--ignore-
) )
sys.exit(1) sys.exit(1)
# ===================================================================== # =====================================================================
@SubCommand( @SubCommand(
"vendor", "vendor",
@ -133,7 +144,7 @@ Please commit or stash these changes before vendoring, or re-run with `--ignore-
vendor_command = self._spawn(VendorRust) vendor_command = self._spawn(VendorRust)
vendor_command.vendor(**kwargs) vendor_command.vendor(**kwargs)
# ===================================================================== # =====================================================================
@SubCommand( @SubCommand(
"vendor", "vendor",

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

@ -46,7 +46,7 @@ class VendorManifest(MozbuildObject):
) )
return return
elif check_for_update: elif check_for_update:
self.log(logging.ERROR, "vendor", {}, commit) print("%s" % commit)
return return
self.fetch_and_unpack(commit) self.fetch_and_unpack(commit)