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

PreReleaseNumber is string instead of integere in new repository #1688

Closed
andreabisiach opened this issue May 24, 2019 · 5 comments · Fixed by #2527
Closed

PreReleaseNumber is string instead of integere in new repository #1688

andreabisiach opened this issue May 24, 2019 · 5 comments · Fixed by #2527
Labels
Milestone

Comments

@andreabisiach
Copy link

Hello,

during some test for a gradle wrapper plugin I have encountered a scenario where PreReleaseNumber returns a "" string instead of an integer.

To reproduce:

mkdir testrepo
cd testrepo
git init
touch somefile
git add .
git commit -m "added somefile"
gitversion

the output shows
"PreReleaseNumber":""

I would expect 0

@asbjornu
Copy link
Member

asbjornu commented Jul 1, 2019

PrereleaseNumber will always be an empty string on stable builds (on master) since it's set to null. As you can see from the source code, all version variables are of the type string and not int:

https://github.com/GitTools/GitVersion/blob/master/src/GitVersionCore/OutputVariables/VersionVariables.cs#L78-L106

@andreabisiach
Copy link
Author

andreabisiach commented Jul 2, 2019

Sorry, I am a bit confused (and excuse my lack of knowledge in this matter),

when I run gitversion, the json output for several values is represented as number and not string (i.e Major, Minor, Patch).
The problem with PreReleaseNumber is that when empty it outputs an empty string, when not empty (like the following example), it outputs a number.

Since the code you link to shows that internally are all represented as string, how comes that the output of gitversion is number for some of them? And I would consider a bug the fact that PreReleaseNumber changes from string to number (as output)

{
  "Major":1,
  "Minor":1,
  "Patch":0,
  "PreReleaseTag":"alpha.1",
  "PreReleaseTagWithDash":"-alpha.1",
  "PreReleaseLabel":"alpha",
  "PreReleaseNumber":1,
  "BuildMetaData":"",
  "BuildMetaDataPadded":"",
  "FullBuildMetaData":"Branch.develop.Sha.312857aec2a85eb8b213fa9b2f078396cb1b0478",
  "MajorMinorPatch":"1.1.0",
  "SemVer":"1.1.0-alpha.1",
  "LegacySemVer":"1.1.0-alpha1",
  "LegacySemVerPadded":"1.1.0-alpha0001",
  "AssemblySemVer":"1.1.0.0",
  "AssemblySemFileVer":"1.1.0.0",
  "FullSemVer":"1.1.0-alpha.1",
  "InformationalVersion":"1.1.0-alpha.1+Branch.develop.Sha.312857aec2a85eb8b213fa9b2f078396cb1b0478",
  "BranchName":"develop",
  "Sha":"312857aec2a85eb8b213fa9b2f078396cb1b0478",
  "ShortSha":"312857a",
  "NuGetVersionV2":"1.1.0-alpha0001",
  "NuGetVersion":"1.1.0-alpha0001",
  "NuGetPreReleaseTagV2":"alpha0001",
  "NuGetPreReleaseTag":"alpha0001",
  "CommitsSinceVersionSource":1,
  "CommitsSinceVersionSourcePadded":"0001",
  "CommitDate":"2019-03-19"
}

@asbjornu
Copy link
Member

I can't recollect or I simply don't know why the variables are serialized to integer when they have a value. You would have to plow through the source code to figure it out – that's what I would have to do as well to give you an answer.

@stale
Copy link

stale bot commented Oct 17, 2019

This issue has been automatically marked as stale because it has not had recent activity. After 30 days from now, it will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Oct 17, 2019
@stale stale bot closed this as completed Nov 16, 2019
dieterv added a commit to dieterv/GitVersion that referenced this issue Jan 10, 2021
Ever since the introduction of the JsonOutputFormatter way back
in 2014 [1] all fields where serialized as JSON string. Except
for values looking like an int which where then serialized as JSON
numbers. This had some strange unpredictable side effects like
PreReleaseNumber being an empty JSON string instead of null
or a "2009069" ShortSha being formatted as a JSON number.

This change ensures all fields are serialized as JSON string
except Major, Minor, Patch, PreReleaseNumber,
WeightedPreReleaseNumber, CommitsSinceVersionSource and
UncommittedChanges which are now always serialized as JSON number.

Deserialisation remains the same as before for all fiels so we
continue to accept both JSON string and JSON number formatted
values for all fields.

Fixes GitTools#1688 and fixes GitTools#2304.

[1] GitTools@f2daf60#diff-fde1a8ff593c6ac2ad558a6f9bb512e0350db91343b185f9b2a00d1d6e848bc3
dieterv added a commit to dieterv/GitVersion that referenced this issue Jan 10, 2021
Ever since the introduction of the JsonOutputFormatter way back
in 2014 [1] all fields where serialized as JSON string. Except
for values looking like an int which where then serialized as JSON
numbers. This had some strange unpredictable side effects like
PreReleaseNumber being an empty JSON string instead of null
or a "2009069" ShortSha being formatted as a JSON number.

This change ensures all fields are serialized as JSON string
except Major, Minor, Patch, PreReleaseNumber,
WeightedPreReleaseNumber, CommitsSinceVersionSource and
UncommittedChanges which are now always serialized as JSON number.

Deserialisation remains the same as before for all fields so we
continue to accept both JSON string and JSON number formatted
values.

Fixes GitTools#1688 and fixes GitTools#2304.

[1] GitTools@f2daf60#diff-fde1a8ff593c6ac2ad558a6f9bb512e0350db91343b185f9b2a00d1d6e848bc3
dieterv added a commit to dieterv/GitVersion that referenced this issue Jan 11, 2021
Ever since the introduction of the JsonOutputFormatter way back
in 2014 [1] all fields where serialized as JSON string. Except
for values looking like an int which where then serialized as JSON
numbers. This had some strange unpredictable side effects like
PreReleaseNumber being an empty JSON string instead of null
or a "2009069" ShortSha being formatted as a JSON number.

This change ensures all fields are serialized as JSON string
except Major, Minor, Patch, PreReleaseNumber,
WeightedPreReleaseNumber, CommitsSinceVersionSource and
UncommittedChanges which are now always serialized as JSON number.

Deserialisation remains the same as before for all fields so we
continue to accept both JSON string and JSON number formatted
values.

Fixes GitTools#1688 and fixes GitTools#2304.

[1] GitTools@f2daf60#diff-fde1a8ff593c6ac2ad558a6f9bb512e0350db91343b185f9b2a00d1d6e848bc3
dieterv added a commit to dieterv/GitVersion that referenced this issue Jan 17, 2021
Ever since the introduction of the JsonOutputFormatter way back
in 2014 [1] all fields where serialized as JSON string. Except
for values looking like an int which where then serialized as JSON
numbers. This had some strange unpredictable side effects like
PreReleaseNumber being an empty JSON string instead of null
or a "2009069" ShortSha being formatted as a JSON number.

This change ensures all fields are serialized as JSON string
except Major, Minor, Patch, PreReleaseNumber,
WeightedPreReleaseNumber, CommitsSinceVersionSource and
UncommittedChanges which are now always serialized as JSON number.

Deserialisation remains the same as before for all fields so we
continue to accept both JSON string and JSON number formatted
values.

Fixes GitTools#1688 and fixes GitTools#2304.

[1] GitTools@f2daf60#diff-fde1a8ff593c6ac2ad558a6f9bb512e0350db91343b185f9b2a00d1d6e848bc3
dieterv added a commit to dieterv/GitVersion that referenced this issue Jan 17, 2021
Ever since the introduction of the JsonOutputFormatter way back
in 2014 [1] all fields where serialized as JSON string. Except
for values looking like an int which where then serialized as JSON
numbers. This had some strange unpredictable side effects like
PreReleaseNumber being an empty JSON string instead of null
or a "2009069" ShortSha being formatted as a JSON number.

This change ensures all fields are serialized as JSON string
except Major, Minor, Patch, PreReleaseNumber,
WeightedPreReleaseNumber, CommitsSinceVersionSource and
UncommittedChanges which are now always serialized as JSON number.

Deserialisation remains the same as before for all fields so we
continue to accept both JSON string and JSON number formatted
values.

Fixes GitTools#1688 and fixes GitTools#2304.

[1] GitTools@f2daf60#diff-fde1a8ff593c6ac2ad558a6f9bb512e0350db91343b185f9b2a00d1d6e848bc3
dieterv added a commit to dieterv/GitVersion that referenced this issue Jan 17, 2021
Ever since the introduction of the JsonOutputFormatter way back
in 2014 [1] all fields where serialized as JSON string. Except
for values looking like an int which where then serialized as JSON
numbers. This had some strange unpredictable side effects like
PreReleaseNumber being an empty JSON string instead of null
or a "2009069" ShortSha being formatted as a JSON number.

This change ensures all fields are serialized as JSON string
except Major, Minor, Patch, PreReleaseNumber,
WeightedPreReleaseNumber, CommitsSinceVersionSource and
UncommittedChanges which are now always serialized as JSON number.

Deserialisation remains the same as before for all fields so we
continue to accept both JSON string and JSON number formatted
values.

Fixes GitTools#1688 and fixes GitTools#2304.

[1] GitTools@f2daf60#diff-fde1a8ff593c6ac2ad558a6f9bb512e0350db91343b185f9b2a00d1d6e848bc3
dieterv added a commit to dieterv/GitVersion that referenced this issue Feb 5, 2021
Ever since the introduction of the JsonOutputFormatter way back
in 2014 [1] all fields where serialized as JSON string. Except
for values looking like an int which where then serialized as JSON
numbers. This had some strange unpredictable side effects like
PreReleaseNumber being an empty JSON string instead of null
or a "2009069" ShortSha being formatted as a JSON number.

This change ensures all fields are serialized as JSON string
except Major, Minor, Patch, PreReleaseNumber,
WeightedPreReleaseNumber, CommitsSinceVersionSource and
UncommittedChanges which are now always serialized as JSON number.

Deserialisation remains the same as before for all fields so we
continue to accept both JSON string and JSON number formatted
values.

Fixes GitTools#1688 and fixes GitTools#2304.

[1] GitTools@f2daf60#diff-fde1a8ff593c6ac2ad558a6f9bb512e0350db91343b185f9b2a00d1d6e848bc3
@asbjornu asbjornu added this to the 5.6.5 milestone Feb 5, 2021
arturcic pushed a commit that referenced this issue Feb 5, 2021
Ever since the introduction of the JsonOutputFormatter way back
in 2014 [1] all fields where serialized as JSON string. Except
for values looking like an int which where then serialized as JSON
numbers. This had some strange unpredictable side effects like
PreReleaseNumber being an empty JSON string instead of null
or a "2009069" ShortSha being formatted as a JSON number.

This change ensures all fields are serialized as JSON string
except Major, Minor, Patch, PreReleaseNumber,
WeightedPreReleaseNumber, CommitsSinceVersionSource and
UncommittedChanges which are now always serialized as JSON number.

Deserialisation remains the same as before for all fields so we
continue to accept both JSON string and JSON number formatted
values.

Fixes #1688 and fixes #2304.

[1] f2daf60#diff-fde1a8ff593c6ac2ad558a6f9bb512e0350db91343b185f9b2a00d1d6e848bc3
@arturcic arturcic added bug and removed stale labels Feb 7, 2021
@github-actions
Copy link

github-actions bot commented Feb 7, 2021

🎉 This issue has been resolved in version 5.6.5 🎉
The release is available on:

Your GitReleaseManager bot 📦🚀

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

Successfully merging a pull request may close this issue.

3 participants