From 81e0cfbf0c656cbcbef1cd1d255ec4128541a7bf Mon Sep 17 00:00:00 2001 From: "Addisu Z. Taddese" Date: Thu, 22 Jan 2026 10:45:11 -0600 Subject: [PATCH] Optimize PR branch calculation This uses `git ls-remote` instead of hitting the Github APIs for getting a list of branches on the fork repo. This is faster and avoids Github's rate limiting. Generated-By: Gemini 2.5 Pro Signed-off-by: Addisu Z. Taddese --- bloom/commands/release.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/bloom/commands/release.py b/bloom/commands/release.py index 35837e00..3ce5636b 100644 --- a/bloom/commands/release.py +++ b/bloom/commands/release.py @@ -744,7 +744,11 @@ def _my_run(cmd, msg=None): _my_run("mkdir -p {base_info[repo]}".format(**locals())) with change_directory(base_info['repo']): _my_run('git init') - branches = [x['name'] for x in gh.list_branches(head_org, head_repo)] + # Use git ls-remote to find existing branches on the fork + ls_remote_cmd = "git ls-remote --heads {rosdistro_fork_url}".format(**locals()) + from bloom.util import check_output + branches_out = check_output(ls_remote_cmd, shell=True) + branches = [l.split()[1].replace('refs/heads/', '') for l in branches_out.splitlines()] new_branch = 'bloom-{repository}-{count}' count = 0 while new_branch.format(repository=repository, count=count) in branches: