From 9ecb4431407e1a7ac6efde4225c2a22b46206846 Mon Sep 17 00:00:00 2001 From: "Addisu Z. Taddese" Date: Thu, 22 Jan 2026 09:59:34 -0600 Subject: [PATCH] Speed up rosdistro cloning with blobless partial clones Replaces the manual `mkdir`, `git init`, and `git pull` sequence used for cloning the rosdistro repository with an optimized `git clone`. Key changes: - Uses `--filter=blob:none` (blobless clone) to drastically reduce the download size by omitting historical file contents. - Ensures that OAuth tokens are not persisted in the local git config. - Includes a fallback to standard clones for Git versions that do not support partial clones (pre-2.20). This change improves both performance and security during the pull request generation phase of the release process. Generated-By: Gemini 2.5 Pro Signed-off-by: Addisu Z. Taddese --- bloom/commands/release.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/bloom/commands/release.py b/bloom/commands/release.py index 35837e00..86cb1b34 100644 --- a/bloom/commands/release.py +++ b/bloom/commands/release.py @@ -741,9 +741,18 @@ def _my_run(cmd, msg=None): rosdistro_url = 'https://{gh.token}:x-oauth-basic@github.com/{base_repo_id}.git'.format(**locals()) fork_template = 'https://{gh.token}:x-oauth-basic@github.com/{head_org}/{head_repo}.git' rosdistro_fork_url = fork_template.format(**locals()) - _my_run("mkdir -p {base_info[repo]}".format(**locals())) + # Use partial clone if available to speed up cloning large rosdistro repo + try: + cmd = "git clone --filter=blob:none {rosdistro_url} " \ + "--branch {base_info[branch]} --single-branch {base_info[repo]}" + _my_run(cmd.format(**locals()), "Cloning rosdistro") + except subprocess.CalledProcessError: + cmd = "git clone {rosdistro_url} " \ + "--branch {base_info[branch]} --single-branch {base_info[repo]}" + _my_run(cmd.format(**locals()), "Cloning rosdistro (fallback to full clone)") with change_directory(base_info['repo']): - _my_run('git init') + # Remove the remote to avoid storing the oauth token in the git config + _my_run("git remote remove origin") branches = [x['name'] for x in gh.list_branches(head_org, head_repo)] new_branch = 'bloom-{repository}-{count}' count = 0 @@ -763,8 +772,6 @@ def _my_run(cmd, msg=None): warning("Skipping the pull request...") return _my_run('git checkout -b {new_branch}'.format(**locals())) - _my_run("git pull {rosdistro_url} {base_info[branch]}".format(**locals()), - "Pulling latest rosdistro branch") rosdistro_index_commit = get_rosdistro_index_commit() if rosdistro_index_commit is not None: _my_run('git reset --hard {rosdistro_index_commit}'.format(**locals()))