GitVersion icon indicating copy to clipboard operation
GitVersion copied to clipboard

Add test for the version argument

Open asbjornu opened this issue 4 years ago • 7 comments

The GitVersion executable currently returns 1.0.0 when invoked with the -version argument. We have no tests for this, so this PR adds such a test. We need to figure out how to return the proper version number, though.

Description

The version numbering of our assemblies has suddenly stopped working and we need to fix it. This PR adds a test to ensure that -version does not return 1.0.0, but we still need to figure out how to fix the problem.

Motivation and Context

Returning 1.0.0 as GitVersion's version number is a bug and needs to be fixed.

How Has This Been Tested?

I added a test that provokes the problem, but I have not yet made any attempt fixing the problem.

Checklist:

  • [x] My code follows the code style of this project.
  • [ ] My change requires a change to the documentation.
  • [ ] I have updated the documentation accordingly.
  • [x] I have added tests to cover my changes.
  • [ ] All new and existing tests passed.

asbjornu avatar Jun 30 '21 23:06 asbjornu

@arturcic, do you have any idea why gitversion -version has started returning 1.0.0?

asbjornu avatar Jul 01 '21 09:07 asbjornu

I suspect the InformationalVersion that the info is read from is not set, and that might be because the executable used in the unit tests is not built with versioning information

arturcic avatar Jul 01 '21 09:07 arturcic

Yeah, that may explain the problem in the unit test, but not in the released executable. I have a Homebrew-installed GitVersion version 5.6.10 that returns 1.0.0:

$ gitversion -version
1.0.0

dotnet-gitversion is installed as version 5.6.7 and for some reason, it works:

$ dotnet gitversion -version
5.6.7+Branch.main.Sha.e991fcfe958eb104c37f4a0fd021ac1d1e0dce49

So either Homebrew GitVersion is broken or something happened between 5.6.7 and 5.6.10 that broke -version.

asbjornu avatar Jul 03 '21 23:07 asbjornu

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[bot] avatar Mar 02 '22 08:03 stale[bot]

I just tested with GitVersion 5.8.2 and it has the same discrepancy between the Homebrew and .NET Tool version:

$ gitversion -version
1.0.0
$ dotnet gitversion -version
5.8.2+Branch.main.Sha.90dc2bedb08ac54498bddcc279cde5c4596a18d3

There has to be something about how the two binaries are built that is different, somehow. Ideas, @arturcic?

asbjornu avatar Mar 02 '22 11:03 asbjornu

I just tested with GitVersion 5.8.2 and it has the same discrepancy between the Homebrew and .NET Tool version:

$ gitversion -version
1.0.0
$ dotnet gitversion -version
5.8.2+Branch.main.Sha.90dc2bedb08ac54498bddcc279cde5c4596a18d3

There has to be something about how the two binaries are built that is different, somehow. Ideas, @arturcic?

@asbjornu I think the Homebrew version does not include the Version information in the Formulae.

These are the properties we set when building the GitVersion.Tool https://github.com/GitTools/GitVersion/blob/support/5.x/build/build/BuildLifetime.cs#L30-L38.

We do not set any of those when publishing in homebrew.

What I suggest is to run the publish 2 times - once to generate a temporary binary of GitVersion to run and obtain the version information, and the second time to run publish with the version information.

Then we can fix this issue.

arturcic avatar Apr 13 '22 06:04 arturcic

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[bot] avatar Sep 21 '22 06:09 stale[bot]

Resolved by https://github.com/Homebrew/homebrew-core/pull/113622.

asbjornu avatar Oct 21 '22 10:10 asbjornu