Skip to content

[Bug] 5.6.5 Not finding Tag in master repo #2590

Closed

Description

@Eneuman

My master branch has a Tag 6.1.0.
It get correctly picked up by version 5.6.4

  INFO [01/28/21 13:53:18:60] Begin: Calculating base versions
    INFO [01/28/21 13:53:18:62] Fallback base version: 0.1.0 with commit count source 1f34f7b0477ebdaba3db9de21c9bc4aa1ba432d9
    INFO [01/28/21 13:53:18:67] Git tag '6.1.0': 6.1.0 with commit count source ee2c143847ae685ad96dedb7020bf563ac535bea
    INFO [01/28/21 13:53:18:72] Found multiple base versions which will produce the same SemVer (6.2.0), taking oldest source for commit counting (Git tag '6.1.0')
    INFO [01/28/21 13:53:18:72] Base version used: Git tag '6.1.0': 6.1.0 with commit count source ee2c143847ae685ad96dedb7020bf563ac535bea
  INFO [01/28/21 13:53:18:72] End: Calculating base versions (Took: 117.57ms)

but in version 5.6.5 it is not found:

INFO [02/09/21 7:24:04:69] Begin: Calculating base versions
    INFO [02/09/21 7:24:04:71] Fallback base version: 0.1.0 with commit count source 1f34f7b0477ebdaba3db9de21c9bc4aa1ba432d9
    INFO [02/09/21 7:24:04:80] Found multiple base versions which will produce the same SemVer (0.2.0), taking oldest source for commit counting (Fallback base version)
    INFO [02/09/21 7:24:04:80] Base version used: Fallback base version: 0.1.0 with commit count source 1f34f7b0477ebdaba3db9de21c9bc4aa1ba432d9
  INFO [02/09/21 7:24:04:80] End: Calculating base versions (Took: 118.04ms)

Activity

  1. luis-fss commented on Feb 9, 2021

    @luis-fss

    I don't know if it's related, but I'm also getting strange behavior.
    I believe that there is a bug between version 5.6.4 and 5.6.6 that causes an incorrect version to be calculated.

    GitVersion 5.6.4 Behavior

    INFO [02/09/21 11:17:14:53] Found multiple base versions which will produce the same SemVer (1.5.5), taking oldest source for commit counting (Git tag 'v1.5.4')

    GitVersion 5.6.6 Behavior

    INFO [02/09/21 11:20:45:54] Found multiple base versions which will produce the same SemVer (1.5.0), taking oldest source for commit counting (Git tag 'v1.4.10')

    GitVersion.yml.txt

    GitVersion-5.6.5.diagnostic.txt
    GitVersion-5.6.6.diagnostic.txt
    GitVersion-5.6.4.diagnostic.txt

  2. arturcic commented on Feb 9, 2021

    @arturcic
    Member

    @gep13 might be related to your fix

  3. gep13 commented on Feb 10, 2021

    @gep13
    Member

    @Eneuman do you have a link to the project where this is occuring?

  4. Eneuman commented on Feb 10, 2021

    @Eneuman
    Author

    It's a private project but you can repo it this way:

    On Azure Dev Ops create a git repo (branch name master).
    Set a tag like 2.0.0
    Create a pipeline and use the the gittools tasks to install latest gitversion and then calculate a new version.

    Use default settings and run a build.

  5. arturcic commented on Feb 10, 2021

    @arturcic
    Member

    Would be great to have a fixture test that reproduce the issue

  6. Eneuman commented on Feb 10, 2021

    @Eneuman
    Author

    I can also verify that going back to version 5.6.4 solves the problem so something have definitely changed.

  7. gep13 commented on Feb 10, 2021

    @gep13
    Member

    @Eneuman are you doing anything "extra" to download additional portions of the git repository? Or how is Azure DevOps performing the checkout of the git repostiory?

    Having a complete Azure DevOps yml file for what you are doing would certainly help in figuring out the underlying issue.

    A change was made in 5.6.5 to specifically address an issue where the incorrect version number was being asserted on a tagged commit when running on GitHub Actions, so it is possible that this change has had a negative impact when running on Azure DevOps, but in order to figure this out, we would need to complete set of steps to reproduce the problem.

  8. Eneuman commented on Feb 10, 2021

    @Eneuman
    Author

    @gep13 The yml file is very basic:

        - task: gitversion/setup@0
          displayName: GitVersion
          inputs:
            versionSpec: '5.6.6'
            includePrerelease: false
    
        - task: gitversion/execute@0
          displayName: GitVersion Execute
          inputs:
            useConfigFile: true
            configFilePath: 'GitVersion.yaml'
    

    and the config file:

    mode: Mainline
    legacy-semver-padding: 3
    build-metadata-padding: 3
    commits-since-version-source-padding: 3
    branches:
      develop:
        tag: preview
      master:
        tag: ''
    

    My gut says this has something to do with the change from "master" to "main" (I diffed 5.6.4 with 5.6.6).
    We are still using "master" as the name of our main branch.

  9. gep13 commented on Feb 10, 2021

    @gep13
    Member

    @Eneuman again to my point, in order to figure this out, we need complete details on how your repository is set up, so that we can start to investigate what is going on.

    The ideal here, if possible, would be for you to setup a public repository, in a way that replicates the problem, and that way, we can start to attempt to figure out what is going on.

    Is this something that you can help with?

  10. Eneuman commented on Feb 10, 2021

    @Eneuman
    Author

    @gep13 sure I can fix that.

    I have setup a public repo at https://caresoftab.visualstudio.com/Test/_git/Test

    The repo has 3 tags:
    image

    git tag reports this:
    3.0.0
    3.1.0
    4.0.0

    gitversion.exe /url https://caresoftab.visualstudio.com/Test/_git/Test /b master /nocache

    {
      "Major": 3,
      "Minor": 0,
      "Patch": 1,
      "PreReleaseTag": "",
      "PreReleaseTagWithDash": "",
      "PreReleaseLabel": "",
      "PreReleaseLabelWithDash": "",
      "PreReleaseNumber": "",
      "WeightedPreReleaseNumber": 60000,
      "BuildMetaData": 1,
      "BuildMetaDataPadded": "0001",
      "FullBuildMetaData": "1.Branch.master.Sha.2b47dfd3facf4dae171d33e11da7990ac9704023",
      "MajorMinorPatch": "3.0.1",
      "SemVer": "3.0.1",
      "LegacySemVer": "3.0.1",
      "LegacySemVerPadded": "3.0.1",
      "AssemblySemVer": "3.0.1.0",
      "AssemblySemFileVer": "3.0.1.0",
      "FullSemVer": "3.0.1+1",
      "InformationalVersion": "3.0.1+1.Branch.master.Sha.2b47dfd3facf4dae171d33e11da7990ac9704023",
      "BranchName": "master",
      "EscapedBranchName": "master",
      "Sha": "2b47dfd3facf4dae171d33e11da7990ac9704023",
      "ShortSha": "2b47dfd",
      "NuGetVersionV2": "3.0.1",
      "NuGetVersion": "3.0.1",
      "NuGetPreReleaseTagV2": "",
      "NuGetPreReleaseTag": "",
      "VersionSourceSha": "bcff8056621e44685ecccead5e9db96e8458c62c",
      "CommitsSinceVersionSource": 1,
      "CommitsSinceVersionSourcePadded": "0001",
      "UncommittedChanges": 1,
      "CommitDate": "2021-02-10"
    }
    

    A quick analysis showed me that LibGit2Sharp tagcollection only contains the 3.0.0 tag.

  11. arturcic commented on Feb 10, 2021

    @arturcic
    Member

    thank you for the sample, we'll have a look

  12. arturcic commented on Feb 10, 2021

    @arturcic
    Member

    I ran the gitversion.exe /url https://caresoftab.visualstudio.com/Test/_git/Test /b master /nocache
    and I got

    {
      "Major": 4,
      "Minor": 0,
      "Patch": 1,
      "PreReleaseTag": "",
      "PreReleaseTagWithDash": "",
      "PreReleaseLabel": "",
      "PreReleaseLabelWithDash": "",
      "PreReleaseNumber": null,
      "WeightedPreReleaseNumber": 60000,
      "BuildMetaData": 1,
      "BuildMetaDataPadded": "0001",
      "FullBuildMetaData": "1.Branch.master.Sha.2b47dfd3facf4dae171d33e11da7990ac9704023",
      "MajorMinorPatch": "4.0.1",
      "SemVer": "4.0.1",
      "LegacySemVer": "4.0.1",
      "LegacySemVerPadded": "4.0.1",
      "AssemblySemVer": "4.0.1.0",
      "AssemblySemFileVer": "4.0.1.0",
      "FullSemVer": "4.0.1+1",
      "InformationalVersion": "4.0.1+1.Branch.master.Sha.2b47dfd3facf4dae171d33e11da7990ac9704023",
      "BranchName": "master",
      "EscapedBranchName": "master",
      "Sha": "2b47dfd3facf4dae171d33e11da7990ac9704023",
      "ShortSha": "2b47dfd",
      "NuGetVersionV2": "4.0.1",
      "NuGetVersion": "4.0.1",
      "NuGetPreReleaseTagV2": "",
      "NuGetPreReleaseTag": "",
      "VersionSourceSha": "bcff8056621e44685ecccead5e9db96e8458c62c",
      "CommitsSinceVersionSource": 1,
      "CommitsSinceVersionSourcePadded": "0001",
      "UncommittedChanges": 0,
      "CommitDate": "2021-02-10"
    }
    
  13. arturcic commented on Feb 10, 2021

    @arturcic
    Member

    I used version 5.6.6, locally

  14. Eneuman commented on Feb 10, 2021

    @Eneuman
    Author

    I added a new file and another tag 5.0.0

    Can you try again now?

  15. 26 remaining items

  16. lbras commented on Oct 1, 2021

    @lbras

    I compiled GitVersion from source and run a git bisect on it between versions 5.6.4 and 5.6.5. The bug appears to have been introduced in commit 8b653e9:

    8b653e9f75cae9c9918a148de23864feaae736f1 is the first bad commit
    commit 8b653e9f75cae9c9918a148de23864feaae736f1
    Author: Artur 
    Date:   Sun Jan 31 12:14:26 2021 +0100
    
        changed the default branch from master to main
    
  17. lbras commented on Oct 1, 2021

    @lbras

    Took a quick look at the code and found the following. Updating line 53 from TrackReleaseBranchesVersionStrategy.cs (MainTagsVersions method) from

    var main = this.repositoryStore.FindBranch(Config.MainBranchKey);

    to

    var main = this.repositoryStore.FindBranch(Config.MainBranchKey);
    if (main == null)
    {
    	// for compatibility reason try to find master if main cannot be found
    	main = this.repositoryStore.FindBranch(Config.MasterBranchKey);
    }

    solves the issue. Now, I'm not familiar with the codebase at all and have no idea of any side effects, but it keeps all existing tests passing.

    Any advice on this? @asbjornu @arturcic

  18. asbjornu commented on Oct 1, 2021

    @asbjornu
    Member

    @lbras, fantastic debugging! If changing from MainBranchKey to MasterBranchKey fixes the issue, I'm wondering whether this bug may be lurking elsewhere in the codebase as well. Perhaps the simplest fix would be for Config.MainBranchKey to return the value of Config.MasterBranchKey if the former is null? With a fix in place, you're welcome to submit a PR, perhaps in draft state, so we can discuss how to progress it.

  19. superjulius commented on Mar 1, 2022

    @superjulius

    We are looking to replace the deprecated GitVersion with the latest GitTools task in Azure Pipelines but we also hit the versioning issue as our repo is using master naming

    @asbjornu @arturcic Is it safe to explicitly target 5.6.4 (no risk of depreciation)? Is there any plan to fix this in 5.x? or more likely to be addressed in 6.x?

  20. asbjornu commented on Mar 1, 2022

    @asbjornu
    Member

    Already published versions of the GitTools task should continue to work, @superjulius. If they are removed, that's beyond our control and up to Microsoft, if anything. There is no plan to fix this beyond us accepting a pull request that fixes it. As none of the maintainers seem to have this issue, we have no incentive to work on it, unfortunately.

  21. added a commit that references this issue on Mar 8, 2022
    10e81a1
  22. asbjornu commented on Mar 8, 2022

    @asbjornu
    Member

    I've submitted #3037 based on @Ibras' suggestions. If you can think of a way to reproduce the issue in a test, I'd be very grateful. If not, I think the fix is worth merging even without a regression test.

  23. added a commit that references this issue on Mar 9, 2022
    62377fc
  24. added a commit that references this issue on Apr 12, 2022
    90d5e6a
  25. added a commit that references this issue on Apr 13, 2022
  26. added this to the milestone on Apr 13, 2022
  27. modified the milestones: , 5.10.0 on Apr 14, 2022
  28. github-actions commented on Apr 14, 2022

    @github-actions

    🎉 This issue has been resolved in version 5.10.0 🎉
    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

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions