Add find_density_branch() function to locate the 'density' branch
build and deploy Speckle functions / publish-automate-function-version (push) Has been cancelled

This commit adds a new function, find_density_branch(), which searches for a branch with the name 'density' in its lowercase form. If found, it prints the name and ID of the branch. If not found, it prints a message indicating that no such branch was found. This function is then used in transport_recolorized_commit() to check if the current automation run data corresponds to the 'density' branch before proceeding with commit recolorization.
This commit is contained in:
Jonathon Broughton
2024-08-04 16:22:23 +01:00
parent 9f1aa11551
commit dee3ff2b63
+12 -1
View File
@@ -404,6 +404,17 @@ def density_summary(
return data, all_densities, all_areas
def find_density_branch(automate_run_data):
client = automate_run_data.client
project_id = automate_run_data.project_id
branches = client.branch.list(project_id, 100, 0)
for branch in branches:
if "density" in branch.name.lower():
print(f"Found 'density' branch: {branch.name}, Branch ID: {branch.id}")
return branch.id
print("No branch with the name 'density' found.")
return None
def transport_recolorized_commit(
automate_context: AutomationContext,
@@ -414,7 +425,7 @@ def transport_recolorized_commit(
# return the commit id of the new commit
# create a new commit on a specific branch - we'll use "dirstat" for now
if automate_context.automation_run_data.branch_name == "density":
if find_density_branch(automate_context.automation_run_data) is not None:
# commits on the density branch cannot be recolored
print("------------------------------------------------")
print("| CANNOT RECOLOR COMMITS ON THE DENSITY BRANCH |")