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

v3.4 regressed version height calculation involving path filters #587

Closed
marcominerva opened this issue Apr 12, 2021 · 12 comments · Fixed by #606
Closed

v3.4 regressed version height calculation involving path filters #587

marcominerva opened this issue Apr 12, 2021 · 12 comments · Fixed by #606
Assignees
Milestone

Comments

@marcominerva
Copy link

marcominerva commented Apr 12, 2021

Hi!

I have a project with this version.json file:

{
	"$schema": "https://raw.githubusercontent.com/dotnet/Nerdbank.GitVersioning/master/src/NerdBank.GitVersioning/version.schema.json",
	"version": "1.2",
	"publicReleaseRefSpec": [
		"^refs/heads/master$" // we release out of master
	],
	"nugetPackageVersion": {
		"semVer": 2
	},
	"pathFilters": [ "." ]
}

With this configuration, If I use Nerdbank.GitVersioning version 3.3.37, everything works like a charm. However, as soon as I update it to the v3.4.194, the git versioning isn't calculated anymore (it is always set to 0).

@AArnott
Copy link
Collaborator

AArnott commented Apr 12, 2021

Thanks for reporting. We have had a few regressions in 3.4 due to switching from libgit2 to our own managed git implementation. See our release notes for how to switch 3.4 back to libgit2 as a potential workaround.

I haven't heard of the symptom you describe. Can you provide repro steps that we can use?

@AArnott AArnott added this to the v3.4 milestone Apr 12, 2021
@marcominerva
Copy link
Author

You can see the problem in this repository: https://github.com/marcominerva/TinyHelpers/tree/develop/src/TinyHelpers. Now the Nerdbank.GitVersioning is version 3.3.37, so when I build the project (that contains the version.json file I shown you above), the version is correctly set to 1.2.xxx. If, instead, I update the version to v3.4.194 and just retry to rebuild the project, the version returns to the 1.2.0.

@AArnott
Copy link
Collaborator

AArnott commented Apr 12, 2021

Great. I can repro the problem. The workaround I linked you to is effective as well. I'll continue investigating.

@AArnott
Copy link
Collaborator

AArnott commented Apr 12, 2021

@qmfrederik this regression is apparently because some code was never converted for the managed git implementation around path filters support:

/*
// If there are no include paths, or any of the include
// paths refer to the root of the repository, then do not
// filter the diff at all.
var diffInclude =
includePaths.Count == 0 || pathFilters.Any(filter => filter.IsRoot)
? null
: includePaths;
// If the diff between this commit and any of its parents
// does not touch a path that we care about, don't bump the
// height.
var relevantCommit =
commit.Parents.Any()
? commit.Parents.Any(parent => ContainsRelevantChanges(commit.GetRepository().Diff
.Compare<TreeChanges>(parent.Tree, commit.Tree, diffInclude, DiffOptions)))
: ContainsRelevantChanges(commit.GetRepository().Diff
.Compare<TreeChanges>(null, commit.Tree, diffInclude, DiffOptions));
*/

Do you recall why this wasn't done? Is it going to be something we can fill in?

@AArnott AArnott added the bug label Apr 12, 2021
@AArnott AArnott changed the title Versione 3.4.194 doesn't work v3.4 regressed version height calculation involving path filters Apr 12, 2021
@qmfrederik
Copy link
Contributor

There's obviously a bug, but I think the intent was that IsRelevantCommit replaces the code which was commented out.

Since you can reproduce the issue, can you share a unit test which reproduces the behavior?

@AArnott
Copy link
Collaborator

AArnott commented Apr 12, 2021

Yes, I'm working on writing a unit test now.

AArnott added a commit that referenced this issue Apr 12, 2021
@AArnott
Copy link
Collaborator

AArnott commented Apr 12, 2021

Test added in the fix587 branch. It passes on libgit2 and fails on managed git. It only repros when the test uses a path filter two folders deep in the tree (1 level deep did not cut it), and included a version bump. @qmfrederik do you have time to investigate?

image

MarcelMichau added a commit to MarcelMichau/fake-survey-generator that referenced this issue Apr 28, 2021
bump ui dependencies
remove flag to use old git implementation for nbgv in api pipeline as it breaks in debian bullseye
have broken versioning temporarily for api until nbgv is fixed: dotnet/Nerdbank.GitVersioning#587
@AArnott AArnott closed this as completed May 29, 2021
@aminzar-access
Copy link

@AArnott just wondering if this has been released already? Thanks.

@AArnott
Copy link
Collaborator

AArnott commented May 31, 2021

@amin-sage It's available on our CI feed here: https://dev.azure.com/andrewarnott/OSS/_packaging?_a=package&feed=PublicCI&package=Nerdbank.GitVersioning&protocolType=NuGet&version=3.4.205&view=overview

Can you test it and give us the thumbs up that it's effective before we push to nuget.org?

@tg73
Copy link
Contributor

tg73 commented May 31, 2021

I just got hit by this issue - I didn't notice straight away and it was very confusing when I started seeing height 0 (height zero) on builds that were previously "sensible" (given that height should never be less than 1 unless using offset). I can confirm that 3.4.205 from the CI feed gives sensible height. Thanks @qmfrederik for the fix!

@AArnott
Copy link
Collaborator

AArnott commented May 31, 2021

I'm pushing 3.4.205 to nuget.org now.

@aminzar-access
Copy link

Works fine here as well, tested with 2 different projects, thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants