Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(git_utils): Allow configurable shallow clone depth in git_cmd_clone #640

Open
wants to merge 19 commits into
base: develop
Choose a base branch
from

Conversation

lexfrei
Copy link

@lexfrei lexfrei commented Feb 19, 2025

This PR enhances the git_cmd_clone function in git_utils.py by adding a new optional parameter depth (default value: 1). This allows users to customize the depth of the shallow clone, enabling faster cloning and reduced data transfer. The default behavior remains unchanged, ensuring backward compatibility.

Changes:
• Updated the function signature of git_cmd_clone to include depth: int = 1.
• Modified the git clone command to use the provided depth value with the --depth flag.
• Retained the --single-branch option for cloning only the default branch.

Rationale:
Introducing a configurable clone depth provides flexibility for users who may need to fetch more or fewer commits based on their specific requirements. This optimization can lead to significant speed improvements and reduced network load when working with large repositories or in environments with limited bandwidth.

Testing:
• Verified that cloning with the default depth (1) functions correctly.
• Confirmed that specifying different depth values works as expected.

Additional Context:
This change aims to improve performance and user control during repository cloning without disrupting existing workflows.

dw-0 and others added 18 commits September 1, 2024 19:02
Merge develop into master
Merge develop into master
Merge develop into master (v6.0.0-alpha.4)
Merge develop into master (v6.0.0-alpha.5)
Merge develop into master (v6.0.0-alpha.6)

fixes dw-0#545
fixes dw-0#553
fixes dw-0#557
Merge develop into master (v6.0.0-alpha.7)

fixes dw-0#561
fixes dw-0#564
fixes dw-0#565
Merge develop into master (Release v6.0.0-alpha.8)
Merge develop into master (Release v6.0.0-alpha.9)
Merge develop into master (Release v6.0.0-alpha.10)
Merge develop into master (Release v6.0.0-alpha.11)
Merge develop into master (Release v6.0.0-alpha.12)
Merge develop into master (Release v6.0.0-alpha.13)
@lexfrei lexfrei changed the title feat(git_utils): enhance git_cmd_clone with depth and single-branch options feat(git_utils): Allow configurable shallow clone depth in git_cmd_clone Feb 20, 2025
@dw-0 dw-0 changed the base branch from master to develop February 20, 2025 19:57
@dw-0 dw-0 linked an issue Feb 20, 2025 that may be closed by this pull request
@dw-0 dw-0 added this to the v6.0.0-alpha.16 milestone Feb 20, 2025
@dw-0
Copy link
Owner

dw-0 commented Feb 20, 2025

Thank you for the PR and for that detailed description. I think this is a good idea and as you can see this is a feature that was requested for a long time. Though, im currently not sure if there will be a significant downside if we make depth 1 the default.
We need to make sure that installs through KIAUH are compatible with Moonrakers own update mechanics, i will get in touch with Moonrakers maintainer and ask if he sees any downside.

One thought i had was, if we should show the user a dialog if he want's to do a shallow clone or not, with a user friendly and not too technical description about what that means and when it would be usefull to do that.

@lexfrei
Copy link
Author

lexfrei commented Feb 21, 2025

A little update for a function. Now you can use it anywhere without any behavior changes and set the depth and branch options where it's already safe. Also, fully documented in code.

P.S. I was so frustrated with the full clone that I didn’t check any issues and just submitted this PR to your repository. I’m glad to see I’m not the only one and that the issue has already been opened.

@dw-0
Copy link
Owner

dw-0 commented Feb 21, 2025

Hi, so i had a talk with the Moonraker maintainer. We shouldn't use shallow clones at all.
There is no guarantee that Moonraker, or precisely the update manager of Moonraker, will correctly work 100% of the time. The issue with shallow clones seems to be, that they do not report their version correctly when using git describe (something that Moonraker uses) as there may be no tags available.

The general recommendation was to use a blobless clone instead which would reduce download size and be faster than a regular clone. Also, it was said that there should be no general issue with using the blobless clone by default, so that could become the new default way of cloning. Moonraker itself uses blobless clones with the update managers "hard reset" functionality.

https://github.blog/open-source/git/get-up-to-speed-with-partial-clone-and-shallow-clone (see "Quick Summary")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

feat: allow to only git clone --depth 1 to reduce repo download sizes
2 participants