Closed MattKotsenas closed 2 months ago
This is a well understood and documented limitation of git-based versioning systems. There simply is no way to make this work without history because we compute the version based on the number of commits in history for which a given version specified in version.json is set.
I've never seen git --no-pager blame version.json
used to get a subset of the blobs, and I guess it must get more than just the blobs, since we need trees and commits too. It's a clever workaround. But we're never going to fetch as part of computing versions so I think you'll have to keep your workaround in place if you intend to continue with your shallow clones.
Strictly speaking, we only need as many commits back as the last bump to the version specified in version.json. We don't walk any further back than that. So a 'shallow' but not too shallow clone would theoretically work, if you wanted to maintain some magic number for the git clone --depth
switch that was low enough to speed up cloning but high enough to allow nb.gv to suuceed.
My team has some large repos that make disabling shallow clones painful. I experimented with blobless / partial clones, however it appears that the managed git implementation doesn't handle this scenario. Here's an exception from a repo cloned via GitHub Actions like this:
and here's the resulting exception (I stripped the prefix
/home/runner/.nuget/packages/nerdbank.gitversioning/3.6.133/build/Nerdbank.GitVersioning.Inner.targets(17,5): error MSB4018:
from each line to make the stacktrace a bit easier)I tried
NBGV_GitEngine='LibGit2'
, but it appears that libgit2 doesn't support partial clones either https://www.github.com/libgit2/libgit2/issues/5564A workaround I can use in the short term is to add the following script step to the pipeline before build to force git to hydrate just the blobs for
version.json
.I'm happy to do the work here / help out however I can, but I'm not sure how best to get started, nor what the design should be. If you have any questions, please let me know. Thanks!