Skip to content

Conversation

@RShirohara
Copy link
Contributor

Description

Add partial clone support to Git repository. (Resolves #370)

Suggestion

Add --partial option to ghq get for partial clone.
The --partial option can specify either blobless or treeless, and each corresponding to the --filter option in git clone.

  • blobless: --filter=blob:none
  • treeless: --filter=tree:0

Example

In blobless clone:

ghq get --partial blobless github.com/x-motemen/ghq

In treeless clone:

ghq get --partial treeless github.com/x-motemen/ghq

@RShirohara RShirohara marked this pull request as ready for review March 10, 2025 16:20
@Songmu Songmu requested a review from Copilot March 14, 2025 07:18
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds support for partial cloning of Git repositories by introducing a new "--partial" flag that accepts either "blobless" or "treeless", and implements the corresponding filter options in the clone command.

  • Added a new "partial" flag in commands.go with validation.
  • Updated clone logic in vcs.go to incorporate filter options for partial clones.
  • Expanded test coverage for the new partial clone functionality in cmd_get_test.go, vcs_test.go, commands_test.go, and getter.go.

Reviewed Changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated no comments.

Show a summary per file
File Description
commands.go Added a new flag for partial clones with validation.
cmd_get_test.go Added test cases for blobless, treeless, and invalid partial options.
vcs.go Implemented filter options based on partial flag values.
vcs_test.go Added tests to verify partial clone filter flags in git commands.
commands_test.go Updated clone argument structure to include the partial flag.
getter.go Propagated the partial option to the repository getter.
cmd_get.go Passed the partial flag from CLI to the clone options.
Comments suppressed due to low confidence (1)

commands.go:48

  • [nitpick] Consider including the allowed values in the error message for improved clarity, e.g., "flag partial value "%v" is not allowed; allowed values are 'blobless' or 'treeless'".
return fmt.Errorf("flag partial value \"%v\" is not allowed", v)

@RShirohara
Copy link
Contributor Author

@Songmu

All checks have been completed and there appear to be no review comments by Copilot.
Are there any items that I need to address?

@Songmu
Copy link
Member

Songmu commented Mar 25, 2025

@RShirohara

Thank you. I think this is a very good pull request.

However, while "blobless" and "treeless" are well-known idioms, I'm not sure whether it's okay to take them as arguments as they are. Do you know of any other tools that take arguments like that?

If there are no other tools with such an argument system, I think it would be good to add a --filter option to ghq clone similar to git, and pass it through to the git command. It would be a raw interface, though.

@RShirohara
Copy link
Contributor Author

@Songmu

Thank you. I was not able to take into account the implementation trends of other commands......

blobless and treeless were used because, like the already supported --shallow option (which will eventually be converted to --depth=1), we wanted to "support commands defined in Git in a more straightforward syntax".

For other common Git helpers, I investigated support for the --filter option on clone command and found the following results:

It will not be consistent with the existing --shallow command, but we will try again to add the --filter option as you commented.

@RShirohara RShirohara marked this pull request as draft March 25, 2025 15:04
@RShirohara RShirohara changed the title feat: support partial clone on Git repository feat: support filter option on Git repository Mar 25, 2025
@Songmu
Copy link
Member

Songmu commented Mar 25, 2025

You're right, it's not consistent with the shallow command... I'm starting to think it's OK as it is.

@Songmu
Copy link
Member

Songmu commented Mar 25, 2025

OK. I would like to accept your original changes. Sorry for the confusion. @RShirohara

@RShirohara RShirohara changed the title feat: support filter option on Git repository feat: support partial clone on Git repository Mar 25, 2025
@Songmu Songmu added the minor label Mar 25, 2025
@RShirohara RShirohara force-pushed the add-partial-clone-support branch from 66a700e to 39c5d07 Compare March 25, 2025 15:25
@RShirohara RShirohara marked this pull request as ready for review March 25, 2025 15:27
@RShirohara
Copy link
Contributor Author

@Songmu

There was a conflict, which has been resolved, and i have confirmed that all unit tests pass on local.

@Songmu Songmu merged commit e0e71a3 into x-motemen:master Mar 25, 2025
4 checks passed
@github-actions github-actions bot mentioned this pull request Mar 25, 2025
@RShirohara RShirohara deleted the add-partial-clone-support branch March 25, 2025 15:35
@RShirohara
Copy link
Contributor Author

Thank you!

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature request: support partial clone

2 participants