From dee3ff2b638f3eb93ec4ba103a64235dfe5b022b Mon Sep 17 00:00:00 2001 From: Jonathon Broughton Date: Sun, 4 Aug 2024 16:22:23 +0100 Subject: [PATCH] Add find_density_branch() function to locate the 'density' branch 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. --- src/objects/objects.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/objects/objects.py b/src/objects/objects.py index f8c4f22..61640a5 100644 --- a/src/objects/objects.py +++ b/src/objects/objects.py @@ -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 |")