Skip to content

feat: blobless clone#92

Open
Owen-Liuyuxuan wants to merge 6 commits intoros-infrastructure:mainfrom
Owen-Liuyuxuan:feat/blobless_clone
Open

feat: blobless clone#92
Owen-Liuyuxuan wants to merge 6 commits intoros-infrastructure:mainfrom
Owen-Liuyuxuan:feat/blobless_clone

Conversation

@Owen-Liuyuxuan
Copy link

@Owen-Liuyuxuan Owen-Liuyuxuan commented Dec 17, 2025

Basic Info

Info Please fill out this column
Ticket(s) this addresses resolves #91;
Primary OS tested on Ubuntu
Is this a breaking change? No
Does this PR contain AI generated software? No;

Description of contribution in a few bullet points

  • For vcs import, add an optional argument blobless-clone
  • In git import:
    • If there is no existing repository, it will perform a blobless clone, then require a follow-up checkout.
    • If there is an existing repository, it will perform fetch with the blobless option.

Related Links:

dirk-thomas/vcstool#283

Description of how this change was tested

  • run precommit before committing.
  • existing test passed.

Based on the current autoware repos, I run the following commands:
image

The resulting directory will have a size difference like this, but all required contents exist:
image

Signed-off-by: YuxuanLiuTier4Desktop <619684051@qq.com>
Copy link
Member

@leander-dsouza leander-dsouza left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is amazing :)
Thank you for raising the issue and proposing a valid solution 🎉

I would suggest adding a couple of tests for robustness, namely:

  • test_import_blobless
  • test_import_blobless_shallow_mutually_exclusive

PS. Since the repository uses local paths for tests, you would get the following warning while running --blobless-clone:

warning: filtering not recognized by server, ignoring

Feel free to include this warning as well in the expected file - import_blobless.txt.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The blobless_clone is an explicit parameter; hence, it needs to be exposed in the constructor.

Suggested change
def __init__(self, args, url, version=None, recursive=False, shallow=False, blobless_clone=False):

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

4ea438f Explicitly construction fixed here.

self.skip_existing = args.skip_existing
self.recursive = recursive
self.shallow = shallow
self.blobless_clone = args.blobless_clone
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a follow-up from the suggestion that requires blobless_clone to be explicit:

Suggested change
self.blobless_clone = args.blobless_clone
self.blobless_clone = blobless_clone

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

4ea438f Explicitly construction fixed here.

repo['url'],
str(repo['version']) if 'version' in repo else None,
recursive=args.recursive,
shallow=args.shallow,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The blobless_clone needs to be added in the ImportCommand.

Suggested change
shallow=args.shallow,
blobless_clone=args.blobless_clone,

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

4ea438f Explicitly construction fixed here.

except (RuntimeError, request.URLError) as e:
print(ansi('redf') + str(e) + ansi('reset'), file=sys.stderr)
return 1
jobs = generate_jobs(repos, args)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The --shallow and --blobless-clone tags need to be mutually exclusive, as when combined, we would neither get file history nor file content:

  • --shallow --> git clone --depth 1: Downloads only 1 commit but fetches all file blobs at that commit. You get a complete working tree but no history.

  • --blobless-clone --> git clone --filter=blob:none: Downloads the full commit history but no file blobs upfront. Blobs are fetched on-demand during checkout.

Suggested change
if args.shallow and args.blobless_clone:
print(
ansi('redf')
+ "'--shallow' and '--blobless-clone' are mutually exclusive options"
+ ansi('reset'),
file=sys.stderr,
)
return 1
jobs = generate_jobs(repos, args)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot! Exclusive fixed here:9ae0833

Comment on lines 415 to 416
cmd_clone += ['--filter=blob:none', '--no-checkout']
checkout_version = command.version
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The earlier method creates a detached HEAD:

git clone --filter=blob:none --no-checkout https://github.com/org/repo .
git checkout heads/main --

In order to get a proper local branch, support with -b needs to be maintained:

Suggested change
cmd_clone += ['--filter=blob:none', '--no-checkout']
checkout_version = command.version
cmd_clone.append('--filter=blob:none')
if version_type == 'branch':
cmd_clone += ['-b', version_name]
checkout_version = None
elif command.version:
cmd_clone.append('--no-checkout')
checkout_version = command.version
else:
checkout_version = None

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a15ab81
46bc9ce

Fix the support with -b

@leander-dsouza leander-dsouza added the enhancement New feature or request label Feb 21, 2026
Signed-off-by: Yuxuan Liu <619684051@qq.com>
Signed-off-by: Yuxuan Liu <619684051@qq.com>
Signed-off-by: Yuxuan Liu <619684051@qq.com>
Signed-off-by: Yuxuan Liu <619684051@qq.com>
Signed-off-by: Yuxuan Liu <619684051@qq.com>
@Owen-Liuyuxuan
Copy link
Author

Owen-Liuyuxuan commented Feb 24, 2026

@leander-dsouza Thanks for the thorough review. I added the fixes required.

For the test,

  • python3 -m unittest test.test_commands.TestCommands.test_import_blobless test.test_commands.TestCommands.test_import_blobless_shallow_mutually_exclusive Locally test passed.
  • I used AI to generate the test codes.
    • The test content looks legit.
    • Warning were originally fixed in the codes -- I prompted AI to transfer the warning texts into the "expected outputs" as required by the review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: Blobless Clone

2 participants