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

Version height calculated differently in 3.4 with new git backend #658

Closed
nmeyering opened this issue Sep 21, 2021 · 5 comments
Closed

Version height calculated differently in 3.4 with new git backend #658

nmeyering opened this issue Sep 21, 2021 · 5 comments
Assignees
Milestone

Comments

@nmeyering
Copy link

nmeyering commented Sep 21, 2021

It seems git version height still yields different results with the new git backend in some cases. This tripped us up because it meant old packages were being overwritten with new ones, causing chaos in our dependency graph.

Seems to be different from #587 since we get a non-zero version and it still happens in 3.4.231?

$ dotnet tool install --global nbgv
You can invoke the tool using the following command: nbgv
Tool 'nbgv' (version '3.4.231') was successfully installed.
$ nbgv.exe get-version
Version:                      1.0.28.5486
AssemblyVersion:              1.0.0.0
AssemblyInformationalVersion: 1.0.28+6e152011
NuGetPackageVersion:          1.0.28
NpmPackageVersion:            1.0.28

and with the old git backend:

$ NBGV_GitEngine=LibGit2 nbgv.exe get-version
Version:                      1.0.49.5486
AssemblyVersion:              1.0.0.0
AssemblyInformationalVersion: 1.0.49+6e152011
NuGetPackageVersion:          1.0.49
NpmPackageVersion:            1.0.49

Nbgv version 3.3.37 yields 1.0.49 also.

The version.json file is:

{
  "$schema": "https://raw.githubusercontent.com/dotnet/Nerdbank.GitVersioning/master/src/NerdBank.GitVersioning/version.schema.json",
  "version": "1.0",
  "pathFilters": ["."],
  "gitCommitIdShortFixedLength": 8,
  "publicReleaseRefSpec": [
    "^refs/heads/develop$"
  ]
}
@AArnott
Copy link
Collaborator

AArnott commented Sep 21, 2021

Ooh, that doesn't sound good. Sorry about the package version overwriting. That sounds terrible.

Can you share your git history / repo so we can use it to study the problem?
What level in your repo is your version.json file found in? Can you tell me about its history, including how long path filters have been in there? Do other version.json files exist in your repo or in the past?

@nmeyering
Copy link
Author

Hey thanks for the quick reply.

Sorry, I can't share the repo itself, but I'll try to give as much context as possible.
The version.json file is two levels deep at the root of its dotnet project (next to the .csproj file): Repository/src/Project/version.json while Repository/.git is the git dir location.
The version.json only has one commit in its history and it's the same commit that also introduced the whole src/Project dir. So therefore the same path filter has always been there.

@AArnott
Copy link
Collaborator

AArnott commented Sep 21, 2021

Thank you. Do you think you could try creating a new repo with a similar path and history structure (no need for 1000s of commits -- just enough to represent the history of the version.json file and perhaps a dummy file in the project dir) to see if you can repro it on a repo you can share?

@nmeyering
Copy link
Author

Ok I took the time and thankfully it was fairly easy to reproduce. All you apparently need is a merge commit with relevant changes in both parents.

If you clone this repo: https://github.com/nmeyering/nbgv-bug-repro

and run

$ nbgv get-version -v VersionHeight; NBGV_GitEngine=LibGit2 nbgv get-version -v VersionHeight
2
3

you should see the output differs.

@AArnott AArnott self-assigned this Sep 21, 2021
@AArnott AArnott added this to the v3.4 milestone Sep 21, 2021
AArnott added a commit that referenced this issue Sep 21, 2021
@AArnott
Copy link
Collaborator

AArnott commented Sep 21, 2021

I have written a unit test to repro the issue using your shared repro as a template. Thank you. I'm investigating a fix.

@AArnott AArnott added the bug label Sep 22, 2021
tg73 added a commit to zanyants/Nerdbank.GitVersioning that referenced this issue Sep 27, 2021
The managed git implementation had it correctly implemented, according to the code comments in the libgit2 implementation. But those code comments did not match the *code* in the libgit2 implementation. As a result, the managed git code did not match.
In this commit I correct the libgit2 impl code comments to describe what the code *actually* does. Then I fix the identical code comment and code in the managed git implementation to match.

Fixes dotnet#658

(cherry picked from commit 96be5aa)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants