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

Pre-release label in git tag #1600

Closed
wants to merge 4 commits into from

Conversation

asbjornu
Copy link
Member

Rebase and conflict resolvement of #1261. Resolves #1261, fixes #1255.

@ruhullahshah
Copy link
Contributor

ruhullahshah commented Feb 25, 2019

The reason for the observed incorrect version number is that GitVersion is somehow sensitive to tags that are of the form v5.0.0-rc.1 or v5.0.0-beta.1. In case the PreReleaseTag is dropped from the Git tag, for instance naming the tag simply as v5.0.0 leads to a successful execution of the testcase reported here.

I see that the chosen versioning strategy is correct. however, this part of the code causes an incorrect version increment, even though it is set to Patch. I think that this part of the code would generally hold true, for instance, bumping the version number on develop from 5.0.0-alpha.1 to 5.0.0-alpha.2, but in this case it is doing the wrong thing.

Any thoughts?

@asbjornu
Copy link
Member Author

Thanks for digging into this, @ruhullahshah. I'm a bit confused, since the tag should only take presedence if it is on the current commit. For the test case in this PR, there is a commit after the tag v5.0.0-rc.1 is added, so according to my understanding, we should end up on this case VersionField.Patch. However, that does not seem to be the case.

@ruhullahshah
Copy link
Contributor

ruhullahshah commented Feb 26, 2019

@asbjornu You are welcome. Your argument is correct, if the tag name did not have a PreReleaseTag, in this case -rc.1. This line of code will not allow it to pass through. Try removing -rc.1 from the test and everything works as expected.

@asbjornu
Copy link
Member Author

Aha, I was caught yet again by the naming confusion discussed in #1054. I instinctively think of git tag every time I read PreReleaseTag, which is why I argue in #1054 that it should be called PreReleaseLabel instead. Okay, so in the presence of a pre-release label, the label's Number will be incremented instead of applying the chosen increment strategy. I'm not sure why that should be correct for any other commits than the one where the git tag is applied, though. So my thought is still the same: Why should the pre-release label affect the increment strategy at all?

@asbjornu
Copy link
Member Author

Also, when thinking of how the test is formulated and #1255 (comment), isn't mode: Mainline more appropriate for the given use case? I'll test how it affects the version number.

@asbjornu asbjornu force-pushed the feature/test-for-1255 branch from ebe5e47 to 205ef81 Compare February 27, 2019 08:56
@asbjornu
Copy link
Member Author

Nope, mode: Mainline does not support pre-release labels: System.NotSupportedException : Mainline development mode doesn't yet support pre-release tags on master.

I still think mode: Mainline is correct for the use case, but we don't support the given use case with Mainline. 🤷‍♂️

@ruhullahshah
Copy link
Contributor

ruhullahshah commented Feb 27, 2019

Your questions are valid and relate more to the specifications and usage of GitVersion. It "might" be true that in this particular case, GitVersion is abused. However, I would like to demonstrate the general problem with a simpler test case:

[Test]
public void ShouldProvideTheCorrectVersionEvenIfPreReleaseLabelExistsInTheGitTag()
{
    using (var fixture = new EmptyRepositoryFixture())
    {
        fixture.Repository.MakeACommit();
        fixture.ApplyTag("1.0.0-oreo.1");
        fixture.BranchTo("develop");
        fixture.Repository.MakeACommit();
        fixture.AssertFullSemver("1.1.0-alpha.1");
    }
}

This simple test fails due to the presence of a PreReleaseLabel (I agree that this is a better naming convention) in the git tag

Is there some documentation, that talks about GitVersion and its assumptions on naming conventions of a git tag? If no, then in my opinion, this should be fixed or the documentation should be updated to declare the assumptions.

@asbjornu asbjornu changed the title Failing test case for bug #1255 Pre-release label in git tag Feb 27, 2019
@asbjornu asbjornu force-pushed the feature/test-for-1255 branch from 16d7b9e to aca64b5 Compare February 27, 2019 13:19
@asbjornu
Copy link
Member Author

Great point, @ruhullahshah. I've added your test to this PR as further proof that something needs to be done about this. I'm just not sure what.

@stale
Copy link

stale bot commented Sep 25, 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 Sep 25, 2019
@stale
Copy link

stale bot commented Dec 24, 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.

@ermshiperete
Copy link
Contributor

#1844/ #1845 seem to be related

@stale
Copy link

stale bot commented Aug 21, 2020

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 Aug 21, 2020
@asbjornu asbjornu removed the stale label Aug 21, 2020
Base automatically changed from master to main January 31, 2021 12:46
@asbjornu asbjornu force-pushed the feature/test-for-1255 branch 2 times, most recently from 094d7c2 to 94fb47b Compare October 25, 2022 10:28
@arturcic arturcic force-pushed the main branch 4 times, most recently from 9801764 to b7a7608 Compare March 4, 2023 13:33
@arturcic arturcic force-pushed the feature/test-for-1255 branch from 94fb47b to ac2d626 Compare March 19, 2023 06:58
@arturcic
Copy link
Member

Closed in favor of #3445

@arturcic arturcic closed this Mar 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

The same version generated twice
5 participants