Skip to content

Commit

Permalink
Add find_density_branch() function to locate the 'density' branch
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
jsdbroughton committed Aug 4, 2024
1 parent 9f1aa11 commit dee3ff2
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/objects/objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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 |")
Expand Down

0 comments on commit dee3ff2

Please sign in to comment.