-
Notifications
You must be signed in to change notification settings - Fork 654
Feature: Support shallow cloning of git repositories #4561
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
Feature: Support shallow cloning of git repositories #4561
Conversation
There was a problem hiding this 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 shallow cloning of git repositories through an explicit flag, allowing users to bypass the full-history clone for improved performance on large repositories. Key changes include the addition of the AllowShallow flag in settings and command-line arguments, updates to GitPreparer to conditionally allow shallow clones, and comprehensive tests and documentation updates supporting the new feature.
Reviewed Changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated no comments.
Show a summary per file
File | Description |
---|---|
src/GitVersion.MsBuild/msbuild/tools/GitVersion.MsBuild.props | Added MSBuild properties and tool arguments for shallow cloning support |
src/GitVersion.Core/PublicAPI.Shipped.txt | Updated public API to expose the new AllowShallow flag |
src/GitVersion.Core/Options/Settings.cs | Introduced the AllowShallow setting |
src/GitVersion.Core/Core/GitPreparer.cs | Modified shallow repository handling to log a warning when AllowShallow is enabled |
src/GitVersion.Core.Tests/Core/GitVersionExecutorTests.cs | Added unit tests to validate the shallow clone behavior with AllowShallow flag |
src/GitVersion.App/Arguments.cs | Included the AllowShallow flag in application arguments |
src/GitVersion.App/ArgumentParserExtensions.cs | Extended boolean arguments to include allowshallow |
src/GitVersion.App/ArgumentParser.cs | Integrated allowshallow parsing logic |
src/GitVersion.App.Tests/ArgumentParserTests.cs | Added tests to verify correct parsing of the allowshallow argument |
docs/input/docs/usage/msbuild.md, docs/input/docs/usage/cli/arguments.md, docs/input/docs/reference/requirements.md | Updated documentation to reflect shallow cloning support |
Comments suppressed due to low confidence (1)
src/GitVersion.App.Tests/ArgumentParserTests.cs:633
- [nitpick] The test method name 'AllowshallowTrueWhenDefined' is inconsistent with the PascalCase used elsewhere for the 'AllowShallow' property. Consider renaming it to 'AllowShallowTrueWhenDefined' for consistency.
public void AllowshallowTrueWhenDefined()
@joaopbnogueira good stuff, mind to rebase on top of |
8b06315
to
4b19250
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me, that will allow to clone a limited amount of commits and still be able to generate the version, but with the risk of computing the correct version, but that's like an acceptable risk if you know what you do
4b19250
to
da29dc5
Compare
Thank you @joaopbnogueira for your contribution! |
Description
This PR adds support for shallow cloning of git repositories. While having the full git history available is the only way to truly be certain of the next version, this is not desirable on larger repositories with many thousands of commits as a full clone can take several minutes and is usually neither desirable nor needed as there is sufficient information (e.g. git tags) available on the N most recent commits to be able to reliably determine the next version without requiring a full clone.
Since this is a special scenario it put behind an explicit flag
allowshallow
to ensure both backwards compatibility and awareness of the user of the tool.Motivation and Context
Observation that the git checkout step on CI pipelines is taking 5-20 minutes on large internal repositories due to having to fetch the whole history as required by GitVersion. This step sometimes represents more time than the rest of the steps, leading to costs and undesirable long iteration cycles.
How Has This Been Tested?
Checklist: