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

versionHeightOffset ignored #1111

Open
skarllot opened this issue Oct 27, 2024 · 6 comments
Open

versionHeightOffset ignored #1111

skarllot opened this issue Oct 27, 2024 · 6 comments

Comments

@skarllot
Copy link

skarllot commented Oct 27, 2024

The migrating documentation says the following:

If you are matching the prior major.minor version and need the build height integer (usually the 3rd integer) of your version to start higher than the last version from your legacy mechanism, set the "buildNumberOffset" field in the version.json file to be equal to or greater than the 3rd integer in the old version.

Besides de property buildNumberOffset being deprecated, this do not work because it detects as a version change and set versionHeightOffset to null.

Ref:

if (versionOptions.VersionHeightOffset != -1 && versionOptions.VersionHeightPosition.HasValue && SemanticVersion.WillVersionChangeResetVersionHeight(versionOptions.Version, newVersion, versionOptions.VersionHeightPosition.Value))
{
// The version will be reset by this change, so remove the version height offset property.
versionOptions.VersionHeightOffset = null;
}

@AArnott
Copy link
Collaborator

AArnott commented Oct 29, 2024

The code you're referencing is from the nbgv prepare-release command, which has nothing to do with how Nerdbank.GitVersioning computes versions.
Please provide more information about what you're trying to achieve, what steps you're taking, and the expected vs. actual result.

@skarllot
Copy link
Author

Hi, I'm trying to add a new version.json file and setting versionHeightOffset value but it is ignored. Regardless the versionHeightOffset value the NBGV keeps returning a version with zeroed height.

@AArnott
Copy link
Collaborator

AArnott commented Oct 31, 2024

Have you committed your new version.json file? You must commit it for it to take effect.

@skarllot
Copy link
Author

skarllot commented Nov 2, 2024

Yes, I committed it

@skarllot
Copy link
Author

skarllot commented Nov 2, 2024

You can test it using this branch: https://github.com/skarllot/Expressions/tree/feature/release-version

@AArnott
Copy link
Collaborator

AArnott commented Nov 2, 2024

Thank you for that repro. Very helpful.
Apparently it's an issue with pathFilters support. You've only just added the root-level version.json file, and so 0 commits (even the commit that added the file) actually touch the src path, and therefore it has a version height of 0. And we evidently don't bother altering it by versionHeightOffset until there's an initial commit.
So it's a temporary problem for you regardless, since the first commit to src will fix it.
I don't use path filters myself and didn't contribute the feature to nbgv so I can't say when or if this bug will be fixed.

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