Conversation
Signed-off-by: YuxuanLiuTier4Desktop <619684051@qq.com>
leander-dsouza
left a comment
There was a problem hiding this comment.
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_bloblesstest_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, ignoringFeel free to include this warning as well in the expected file - import_blobless.txt.
vcs2l/commands/import_.py
Outdated
There was a problem hiding this comment.
The blobless_clone is an explicit parameter; hence, it needs to be exposed in the constructor.
| def __init__(self, args, url, version=None, recursive=False, shallow=False, blobless_clone=False): |
vcs2l/commands/import_.py
Outdated
| self.skip_existing = args.skip_existing | ||
| self.recursive = recursive | ||
| self.shallow = shallow | ||
| self.blobless_clone = args.blobless_clone |
There was a problem hiding this comment.
This is a follow-up from the suggestion that requires blobless_clone to be explicit:
| self.blobless_clone = args.blobless_clone | |
| self.blobless_clone = blobless_clone |
| repo['url'], | ||
| str(repo['version']) if 'version' in repo else None, | ||
| recursive=args.recursive, | ||
| shallow=args.shallow, |
There was a problem hiding this comment.
The blobless_clone needs to be added in the ImportCommand.
| shallow=args.shallow, | |
| blobless_clone=args.blobless_clone, |
| except (RuntimeError, request.URLError) as e: | ||
| print(ansi('redf') + str(e) + ansi('reset'), file=sys.stderr) | ||
| return 1 | ||
| jobs = generate_jobs(repos, args) |
There was a problem hiding this comment.
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.
| 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) |
vcs2l/clients/git.py
Outdated
| cmd_clone += ['--filter=blob:none', '--no-checkout'] | ||
| checkout_version = command.version |
There was a problem hiding this comment.
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:
| 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 |
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>
|
@leander-dsouza Thanks for the thorough review. I added the fixes required. For the test,
|
Basic Info
Description of contribution in a few bullet points
blobless-cloneRelated Links:
dirk-thomas/vcstool#283
Description of how this change was tested
Based on the current autoware repos, I run the following commands:

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