mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 13:21:05 +00:00
Bug 1792224: Do some refactoring in preparation for real work r=jewilde
If there is a vendoring section missing in the moz.yaml, we will error out. Detect this right away and give a better error. Perform some cleanup since we know we have a vendoring section. Differential Revision: https://phabricator.services.mozilla.com/D158046
This commit is contained in:
parent
13b99c9dd4
commit
c07c036c14
@ -89,6 +89,11 @@ def vendor(
|
||||
print(e)
|
||||
sys.exit(1)
|
||||
|
||||
if "vendoring" not in manifest:
|
||||
raise Exception(
|
||||
"Cannot perform update actions if we don't have a 'vendoring' section in the moz.yaml"
|
||||
)
|
||||
|
||||
if patch_mode and patch_mode not in ["none", "only"]:
|
||||
print(
|
||||
"Unknown patch mode given '%s'. Please use one of: 'none' or 'only'."
|
||||
|
@ -78,27 +78,7 @@ class VendorManifest(MozbuildObject):
|
||||
self.yaml_file
|
||||
)
|
||||
|
||||
self.source_host = self.get_source_host()
|
||||
|
||||
# Check that updatebot key is available for libraries with existing
|
||||
# moz.yaml files but missing updatebot information
|
||||
if "vendoring" in self.manifest:
|
||||
ref_type = self.manifest["vendoring"]["tracking"]
|
||||
if revision == "tip":
|
||||
new_revision, timestamp = self.source_host.upstream_commit("HEAD")
|
||||
elif ref_type == "tag":
|
||||
new_revision, timestamp = self.source_host.upstream_tag(revision)
|
||||
else:
|
||||
new_revision, timestamp = self.source_host.upstream_commit(revision)
|
||||
else:
|
||||
ref_type = "commit"
|
||||
new_revision, timestamp = self.source_host.upstream_commit(revision)
|
||||
|
||||
self.logInfo(
|
||||
{"ref_type": ref_type, "ref": new_revision, "timestamp": timestamp},
|
||||
"Latest {ref_type} is {ref} from {timestamp}",
|
||||
)
|
||||
|
||||
# ==========================================================
|
||||
# If we're only patching; do that
|
||||
if "patches" in self.manifest["vendoring"] and patch_mode == "only":
|
||||
self.import_local_patches(
|
||||
@ -108,6 +88,26 @@ class VendorManifest(MozbuildObject):
|
||||
)
|
||||
return
|
||||
|
||||
# ==========================================================
|
||||
self.source_host = self.get_source_host()
|
||||
|
||||
ref_type = self.manifest["vendoring"]["tracking"]
|
||||
flavor = self.manifest["vendoring"].get("flavor", "regular")
|
||||
|
||||
if revision == "tip":
|
||||
# This case allows us to force-update a tag-tracking library to master
|
||||
new_revision, timestamp = self.source_host.upstream_commit("HEAD")
|
||||
elif ref_type == "tag":
|
||||
new_revision, timestamp = self.source_host.upstream_tag(revision)
|
||||
else:
|
||||
new_revision, timestamp = self.source_host.upstream_commit(revision)
|
||||
|
||||
self.logInfo(
|
||||
{"ref_type": ref_type, "ref": new_revision, "timestamp": timestamp},
|
||||
"Latest {ref_type} is {ref} from {timestamp}",
|
||||
)
|
||||
|
||||
# ==========================================================
|
||||
if not force and self.manifest["origin"]["revision"] == new_revision:
|
||||
# We're up to date, don't do anything
|
||||
self.logInfo({}, "Latest upstream matches in-tree.")
|
||||
@ -117,11 +117,13 @@ class VendorManifest(MozbuildObject):
|
||||
print("%s %s" % (new_revision, timestamp))
|
||||
return
|
||||
|
||||
flavor = self.manifest["vendoring"].get("flavor", "regular")
|
||||
# ==========================================================
|
||||
if flavor == "regular":
|
||||
self.process_regular(
|
||||
new_revision, timestamp, ignore_modified, add_to_exports
|
||||
)
|
||||
elif flavor == "individual-files":
|
||||
self.process_individual(new_revision, timestamp, ignore_modified)
|
||||
elif flavor == "rust":
|
||||
self.process_rust(
|
||||
command_context,
|
||||
@ -154,6 +156,24 @@ class VendorManifest(MozbuildObject):
|
||||
|
||||
self.update_yaml(new_revision, timestamp)
|
||||
|
||||
def process_individual(self, new_revision, timestamp, ignore_modified):
|
||||
|
||||
# TBD
|
||||
|
||||
self.update_yaml(new_revision, timestamp)
|
||||
|
||||
self.logInfo({"rev": new_revision}, "Updated to '{rev}'.")
|
||||
|
||||
if "patches" in self.manifest["vendoring"]:
|
||||
# Remind the user
|
||||
self.log(
|
||||
logging.CRITICAL,
|
||||
"vendor",
|
||||
{},
|
||||
"Patches present in manifest!!! Please run "
|
||||
"'./mach vendor --patch-mode only' after commiting changes.",
|
||||
)
|
||||
|
||||
def process_regular(self, new_revision, timestamp, ignore_modified, add_to_exports):
|
||||
|
||||
if self.should_perform_step("fetch"):
|
||||
|
Loading…
Reference in New Issue
Block a user