Skip to content

Commit

Permalink
bot fixes (#1553)
Browse files Browse the repository at this point in the history
  • Loading branch information
DerThorsten authored Jan 14, 2025
1 parent 031c11f commit c5dab3f
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions emci/bot/bump_recipes_versions.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,11 @@ def update_recipe_version(recipe_file, new_version, new_sha256, is_ratler):
with open(recipe_file, 'w') as file:
YAML().dump(recipe, file)

def make_pr_title(name, old_version, new_version):
return f"Update {name} from {old_version} to {new_version}"
def make_pr_title(name, old_version, new_version, target_pr_branch_name):
if target_pr_branch_name == "main":
return f"Update {name} from {old_version} to {new_version}"
else:
return f"Update {name} from {old_version} to {new_version} [{target_pr_branch_name}]"

def bump_recipe_version(recipe_dir, target_pr_branch_name):

Expand Down Expand Up @@ -151,6 +154,8 @@ def bump_recipe_version(recipe_dir, target_pr_branch_name):


branch_name = f"bump-{name}_{current_version}_to_{new_version}"
if target_pr_branch_name != "main":
branch_name = f"{target_pr_branch_name}_{target_pr_branch_name}"


with git_branch_ctx(branch_name, stash_current=False):
Expand All @@ -163,7 +168,7 @@ def bump_recipe_version(recipe_dir, target_pr_branch_name):

# commit the changes and make a PR
pr_title = make_pr_title(name, current_version, new_version)
print(f"Making PR for {name} with title: {pr_title}")
print(f"Making PR for {name} with title: {pr_title} with target branch {target_pr_branch_name}")
make_pr_for_recipe(recipe_dir=recipe_dir, pr_title=pr_title, branch_name=branch_name,
target_branch_name=target_pr_branch_name,
automerge=automerge)
Expand Down Expand Up @@ -227,7 +232,7 @@ def user_ctx(user, email, bypass=False):


def bump_recipe_versions(recipe_dir, pr_target_branch, use_bot=True, pr_limit=1):

print(f"Bumping recipes in {recipe_dir} to {pr_target_branch}")
# empty context manager
@contextlib.contextmanager
def empty_context_manager():
Expand Down Expand Up @@ -264,6 +269,7 @@ def empty_context_manager():
print("checkout done")

assert get_current_branch_name() == pr_target_branch
current_branch_name = target_branch_name

# Check for opened PRs and merge them if the CI passed
print("Checking opened PRs and merge them if green!")
Expand Down Expand Up @@ -311,7 +317,7 @@ def empty_context_manager():
total_bumped = 0
for recipe in all_recipes:
try:
bumped_version, old_version, new_version = bump_recipe_version(recipe, current_branch_name)
bumped_version, old_version, new_version = bump_recipe_version(recipe, pr_target_branch)
if bumped_version:
print(f"Bumped {recipe} from {old_version} to {new_version}")
total_bumped += int(bumped_version)
Expand Down

0 comments on commit c5dab3f

Please sign in to comment.