Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add minimum version check for version id dependencies #3767

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
22 changes: 22 additions & 0 deletions cumulusci/core/config/org_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,28 @@ def has_minimum_package_version(self, package_identifier, version_identifier):

return installed_version[0].number >= version_identifier

def get_package_from_version(self, package_version_id, installationkey=None):
"""Fetch and return the package details based on a provided package version ID.
Find the SubscriberPackageVersion for the 04t Id provided in package_version_id
If no package is found return None. If a package is found return the first record
(assuming that the query will only return one record for a specific Id)."""

query = (
"tooling/query/?q=SELECT Id, SubscriberPackageId, MajorVersion, "
"MinorVersion, PatchVersion, BuildNumber from SubscriberPackageVersion "
f"WHERE Id = '{package_version_id}'"
)
if installationkey:
query += f" AND InstallationKey = '{installationkey}'"

response = self.salesforce_client.restful(query)

if not response or "records" not in response or not response["records"]:
return None

package = response["records"][0]
return package

@property
def installed_packages(self):
"""installed_packages is a dict mapping a namespace or package Id (033*) to the installed package
Expand Down
14 changes: 14 additions & 0 deletions cumulusci/core/dependencies/dependencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -519,6 +519,20 @@ def install(
)
return

package = org.get_package_from_version(self.version_id, options.password)

if package:
package_id = package["SubscriberPackageId"]
package_version_number = f"{package['MajorVersion']}.{package['MinorVersion']}.{package['PatchVersion']}"

if org.has_minimum_package_version(
package_id,
package_version_number,
):
context.logger.info(
f"{self} or a newer version is already installed; skipping."
)
return
context.logger.info(f"Installing {self.description}")
install_package_by_version_id(
context,
Expand Down