Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[Bug] Regression: GitVersion 5.12.0 uses only MajorMinorPatch from tag instead of SemVer #3487

@d5UtQvp8QQU9

Description

@d5UtQvp8QQU9

Describe the bug
For tagged commits, GitVersion 5.12.0 ignores PreReleaseTagWithDash and applies only MajorMinorPatch from tag.
For versions before that (e.g. GitVersion.MsBuild 5.11.1) the full SemVer from the tag would be used.

Expected Behavior

If i tag a git commit with or without the appropriate tag-prefix followed by a SemVer, GitVersion should use that SemVer.

Actual Behavior

If i tag a git commit with or without the appropriate tag-prefix followed by a SemVer, GitVersion uses only MajorMinorPatch and ignores any PreReleaseTagWithDash

Possible Fix

Steps to Reproduce

Test1 (without tag-prefix):

    [Test]
    public void GivenARepositoryWithSingleCommitAndSingleBranchAndSemVerTag()
    {
        using var fixture = new EmptyRepositoryFixture();
        const string taggedVersion = "1.0.3-beta.14";
        fixture.Repository.MakeATaggedCommit(taggedVersion);
        fixture.Checkout(taggedVersion);

        fixture.AssertFullSemver(taggedVersion);
    }

Result:

 GivenARepositoryWithSingleCommitAndSingleBranchAndSemVerTag
   Source: TagCheckoutScenarios.cs line 34
   Duration: 493 ms

  Message: 
Shouldly.ShouldAssertException : variables.FullSemVer
    should be
"1.0.3-beta.14"
    but was
"1.0.3"
    difference
Difference     |                           |    |    |    |    |    |    |    |   
               |                          \|/  \|/  \|/  \|/  \|/  \|/  \|/  \|/  
Index          | 0    1    2    3    4    5    6    7    8    9    10   11   12   
Expected Value | 1    .    0    .    3    -    b    e    t    a    .    1    4    
Actual Value   | 1    .    0    .    3                                            
Expected Code  | 49   46   48   46   51   45   98   101  116  97   46   49   52   
Actual Code    | 49   46   48   46   51                                           

  Stack Trace: 
GitToolsTestingExtensions.AssertFullSemver(RepositoryFixtureBase fixture, String fullSemver, Config configuration, IRepository repository, String commitId, Boolean onlyTrackedBranches, String targetBranch) line 116
TagCheckoutScenarios.GivenARepositoryWithSingleCommitAndSingleBranchAndSemVerTag() line 41

  Standard Output: 
Initialized empty Git repository in {USERPROFILE}/AppData/Local/Temp/TestRepositories/{UUID}/.git/
Created git repository at '{USERPROFILE}\AppData\Local\Temp\TestRepositories\{UUID}'
---------
* 2a3eb43 58 minutes ago  (HEAD, tag: 1.0.3-beta.14, main)
**Visualisation of test:**

@startuml
@enduml

Test2 (with tag-prefix):

    [Test]
    public void GivenARepositoryWithSingleCommitAndSingleBranchAndPrefixedSemVerTag()
    {
        using var fixture = new EmptyRepositoryFixture();
        const string semVer = "1.0.3-beta.14";
        const string taggedVersion = $"v{semVer}";
        fixture.Repository.MakeATaggedCommit(taggedVersion);
        fixture.Checkout(taggedVersion);

        fixture.AssertFullSemver(semVer);
    }

Result:

 GivenARepositoryWithSingleCommitAndSingleBranchAndPrefixedSemVerTag
   Source: TagCheckoutScenarios.cs line 45
   Duration: 454 ms

  Message: 
Shouldly.ShouldAssertException : variables.FullSemVer
    should be
"1.0.3-beta.14"
    but was
"1.0.3"
    difference
Difference     |                           |    |    |    |    |    |    |    |   
               |                          \|/  \|/  \|/  \|/  \|/  \|/  \|/  \|/  
Index          | 0    1    2    3    4    5    6    7    8    9    10   11   12   
Expected Value | 1    .    0    .    3    -    b    e    t    a    .    1    4    
Actual Value   | 1    .    0    .    3                                            
Expected Code  | 49   46   48   46   51   45   98   101  116  97   46   49   52   
Actual Code    | 49   46   48   46   51                                           

  Stack Trace: 
GitToolsTestingExtensions.AssertFullSemver(RepositoryFixtureBase fixture, String fullSemver, Config configuration, IRepository repository, String commitId, Boolean onlyTrackedBranches, String targetBranch) line 116
TagCheckoutScenarios.GivenARepositoryWithSingleCommitAndSingleBranchAndPrefixedSemVerTag() line 53

  Standard Output: 
Initialized empty Git repository in {USERPROFILE}/AppData/Local/Temp/TestRepositories/{UUID}/.git/
Created git repository at '{USERPROFILE}\AppData\Local\Temp\TestRepositories\{UUID}'
---------
* e64df05 58 minutes ago  (HEAD, tag: v1.0.3-beta.14, main)
**Visualisation of test:**

@startuml
@enduml

Context

Your Environment

  • Version Used: 5.12.0
  • Operating System and version (Windows 10, Ubuntu 18.04): Windows 10
  • Link to your project: -
  • Link to your CI build (if appropriate): -

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions