-
Notifications
You must be signed in to change notification settings - Fork 652
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
Check that repository isn't a shallow clone and show an error if it is #3479
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.
This looks promising! How do you suggest figuring out whether a repository is a shallow clone or not? Is this information LibGit2Sharp exposes?
@asbjornu yes it seems to be supporting https://github.com/libgit2/libgit2sharp/blob/8c32b6160a49890e26100148e73c1558b0daa9af/LibGit2Sharp/RepositoryInformation.cs#L28, Also in this PR you can see https://github.com/GitTools/GitVersion/pull/3479/files#diff-6d64c4b71b687750cfe54b49765fe58ccacf69a80c86a2e449cec0be3ebf3596R23 |
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.
I would love to have a test that exercises this code somehow. Perhaps it's possible to create a shallow clone in the integration tests somehow?
Yeah, GitHub was acting up a bit so all the changed files weren't showing in the code review. It looks like a great way to solve this problem, we just need to figure out a way to test it. :) |
Something similar to the dynamic clone tests? that will clone the GitVersion repo but with the depth=1 |
It turns out LibGit2Sharp doesn't support setting the depth when cloning, so I had to make a work around that does a shallow pull and a garbage collection with pruning afterwards. Let me know if you see a better way to test it. |
That is exactly what I was checking and wanted to suggest. Good catch |
@kimsey0 can you please rebase your PR branch on the latest main? then I think after the build succeeds we can merge |
…ed to disable shallow fetching
Sure thing! Done. |
@asbjornu please have a new look and if it works for you please merge this one |
@kimsey0 Thank you very much taking the time. I have found this article https://github.blog/2020-12-21-get-up-to-speed-with-partial-clone-and-shallow-clone/ which discribes the option we have in git very good. Following is written:
My question is: Does GitVersion support |
@HHobeck: I don't know. I have never heard of treeless partial clones before. It might be worth opening a new issue about if you would like to explore it. |
@HHobeck Libgit2 that is bundled in LibGit2Sharp that GitVersion uses does not have shallow clone support libgit2/libgit2#3058 |
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.
Just a tiny typo, otherwise this is fantastic! 🚀 👏🏼 🎉
Fix typo: will -> to.
Thank you @kimsey0 for your contribution! |
@asbjornu: I was going to fix the same typo in
|
@kimsey0, oh well. Let's leave that as an opportunity for you to fix in your next PR, then. 😃 |
🎉 This issue has been resolved in version 6.0.0-beta.3 🎉 Your GitReleaseManager bot 📦🚀 |
Description
This change detects shallow repositories and exits early with a proper error message.
Related Issue
Fixes #3188.
Motivation and Context
Since September 2022, Azure DevOps has shallow fetch enabled by default in new pipelines. GitVersion doesn't work with shallowly cloned repositories and currently shows a hard-to-debug error message about a
NullReferenceException
inLibGit2Sharp
when encountering such a repository. A better error message will make it easier for users to find and disable shallow fetching.How Has This Been Tested?
This has an automated test that creates a shallow copy and asserts that the correct error message is shown.
Checklist: