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

Does GitVersioning work with partial tree checkouts? #1123

Open
CoenraadS opened this issue Dec 2, 2024 · 1 comment
Open

Does GitVersioning work with partial tree checkouts? #1123

CoenraadS opened this issue Dec 2, 2024 · 1 comment

Comments

@CoenraadS
Copy link

CoenraadS commented Dec 2, 2024

Hello

I was reading this post:

https://github.blog/open-source/git/get-up-to-speed-with-partial-clone-and-shallow-clone/

Which states --filter=tree:0 can be used to still get the git history, which I think is enough information to calculate the git height while speeding up git checkout by not downloading unnecessary data.

But when I enabled it in github actions:

     - uses: actions/checkout@v4
        with:
          show-progress: false
          lfs: 'true'
          filter: tree:0 
          fetch-depth: 0 
          sparse-checkout: |
            .github
            src

nbgv get-version throws an exception:

Unhandled exception: System.InvalidOperationException: Unable to get version from commit: 0f5510eaf09d88f7b102af37186a716093087fc4
 ---> Nerdbank.GitVersioning.GitException: An tree object with SHA 3f4ff30cf90fe50997c09702a57d01ebf5c9d53f could not be found.
   at Nerdbank.GitVersioning.ManagedGit.GitRepository.GetObjectBySha(GitObjectId sha, String objectType)
   at Nerdbank.GitVersioning.ManagedGit.GitRepository.GetTreeEntry(GitObjectId treeId, ReadOnlySpan`1 nodeName)
   at Nerdbank.GitVersioning.Managed.ManagedVersionFile.GetVersion(GitCommit commit, String repoRelativeProjectDirectory, Dictionary`2 blobVersionCache, String& actualDirectory)
   at Nerdbank.GitVersioning.Managed.GitExtensions.GitWalkTracker.GetVersion(GitCommit commit)
@AArnott
Copy link
Collaborator

AArnott commented Dec 2, 2024

I've never tested that scenario. I don't know how git tree objects are supposed to exist in sparse checkout scenarios so I suppose it makes sense that that operation would fail. Whether there's a workaround or not... there probably is somewhere. But adding support for this isn't something that I'm going to personally have time to do. If you're interested in sending a PR with a test and the new code to support it, I'd welcome it though.

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

No branches or pull requests

2 participants