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

[Bug] the presence of an outdated next-version configuration breaks the version resolution #2670

Closed
franknarf8 opened this issue Apr 26, 2021 · 8 comments
Labels

Comments

@franknarf8
Copy link

franknarf8 commented Apr 26, 2021

Describe the bug

See discussion here : #2660

With this dummy git repo :

*   0bac05d 3 minutes ago  (HEAD -> master)
|\
| * 2922409 3 minutes ago  (feature/first-feature)
| * 2246a3e 7 minutes ago
|/
* bc00c9f 7 minutes ago  (tag: 1.2.3)

The following config resolves (incorrectly) to 1.2.3 :

mode: Mainline
next-version: 1.0.0
branches:
  release:
    tag: 'rc'
  feature:
    regex: ^features?[/-]|^(pull|pull\-requests|pr)[/-]
    tag: 'dev'
  develop:
    tag: 'a'
  hotfix:
    tag: 'post'
ignore:
  sha: []
merge-message-formats: {}

whereas this config resolves (correctly) to 1.2.4 :

mode: Mainline
branches:
  release:
    tag: 'rc'
  feature:
    regex: ^features?[/-]|^(pull|pull\-requests|pr)[/-]
    tag: 'dev'
  develop:
    tag: 'a'
  hotfix:
    tag: 'post'

Expected Behavior

GitVersion should resolve to 1.2.4 with both configurations

Actual Behavior

The first config resolves (incorrectly) to 1.2.3

Possible Fix (Workaround)

Removing the next-version configuration to achieve the expected behavior.

Context

See discussion : #2660

Your Environment

GitVersion 5.6.8
Windows 10

@franknarf8 franknarf8 added the bug label Apr 26, 2021
@mchippingtonderrick-afl
Copy link

Aha! I've been trying to track down a tricky versioning issue for months; and it seems like this may well be the culprit.

@DavidDeSloovere
Copy link

DavidDeSloovere commented May 20, 2021

I'm also getting this issue with GitVersion.Tool 5.6.9 x64 in Azure Pipelines.
Need to remove next-version from config or I keep getting the old version back.
Checked the logs and seemed to work fine with GitVersion.Tool 5.3.7 x64

Edit: I can confirm that 5.3.7 works as expected and that the bug started with 5.5.0

My config

mode: Mainline
next-version: 2.29.0
assembly-versioning-scheme: Major
branches:
  pull-request:
    tag: pr
ignore:
  sha: []
merge-message-formats: {}

Expecting a patch version higher than 11.

Some output


Command: dotnet-gitversion E:/agent-daredevil/_work/5/s /output json /output buildserver /updateprojectfiles
E:\agent-daredevil\_work\_tool\GitVersion.Tool\5.6.9\x64\dotnet-gitversion.exe E:/agent-daredevil/_work/5/s /output json /output buildserver /updateprojectfiles
INFO [05/20/21 13:39:26:29] Working directory: E:/agent-daredevil/_work/5/s
INFO [05/20/21 13:39:26:32] Branch from build environment: refs/heads/master
INFO [05/20/21 13:39:26:32] Project root is: E:\agent-daredevil\_work\5\s\
INFO [05/20/21 13:39:26:32] DotGit directory is: E:\agent-daredevil\_work\5\s\.git
INFO [05/20/21 13:39:26:32] Begin: Normalizing git directory for branch 'refs/heads/master'
  INFO [05/20/21 13:39:26:36] One remote found (origin -> 'https://REDACTED').
  INFO [05/20/21 13:39:26:36] Skipping fetching, if GitVersion does not calculate your version as expected you might need to allow fetching or use dynamic repositories
  INFO [05/20/21 13:39:26:38] Updating local branch master to point at f24d72a Merged PR 10536: REDACTED
....
  INFO [05/20/21 13:39:26:51] Creating local branch from remote tracking 'refs/remotes/origin/f24d72af940596018b89b3b772f026447a87fae4'.
....

  INFO [05/20/21 13:39:26:57] HEAD points at branch 'refs/heads/master'.
  INFO [05/20/21 13:39:26:57] End: Normalizing git directory for branch 'refs/heads/master' (Took: 252.44ms)
  INFO [05/20/21 13:39:26:60] Begin: Loading version variables from disk cache
    INFO [05/20/21 13:39:26:60] Cache file E:\agent-daredevil\_work\5\s\.git\gitversion_cache\8CE33F54F11FA306A86056180974F3A478BCD8DE.yml not found.
  INFO [05/20/21 13:39:26:60] End: Loading version variables from disk cache (Took: 0.51ms)
  INFO [05/20/21 13:39:26:71] Using latest commit on specified branch
  INFO [05/20/21 13:39:26:81] Running against branch: master (f24d72a Merged PR 10536: REDACTED)
  INFO [05/20/21 13:39:26:82] Begin: Calculating base versions
    INFO [05/20/21 13:39:26:83] NextVersion in GitVersion configuration file: 2.29.0 with commit count source External Source
    INFO [05/20/21 13:39:26:91] Fallback base version: 0.1.0 with commit count source faa3ad7bea7b25d560f13bc088d3a998f9ecc747
    INFO [05/20/21 13:39:27:20] Git tag '2.29.11': 2.29.11 with commit count source ec6010ca0e3fb565d386c53d5b2a958cd0678faa
    INFO [05/20/21 13:39:27:20] Git tag '2.29.8': 2.29.8 with commit count source 924a7f038c3f805d431ef8dae579dcc5c77a3a69

......

    INFO [05/20/21 13:39:27:41] Found multiple base versions which will produce the same SemVer (2.29.12), taking oldest source for commit counting (Git tag '2.29.11')
    INFO [05/20/21 13:39:27:41] Base version used: Git tag '2.29.11': 2.29.11 with commit count source ec6010ca0e3fb565d386c53d5b2a958cd0678faa
  INFO [05/20/21 13:39:27:41] End: Calculating base versions (Took: 596.09ms)
  INFO [05/20/21 13:39:27:41] 6 commits found between ec6010c Merged PR 10483: REDACTED and f24d72a Merged PR 10536: REDACTED
  INFO [05/20/21 13:39:27:42] Begin: Using mainline development mode to calculate current version
    INFO [05/20/21 13:39:27:44] Found possible mainline branches: master
    INFO [05/20/21 13:39:27:47] Mainline for current branch is master
    INFO [05/20/21 13:39:27:47] 6 commits found between ec6010c Merged PR 10483: REDACTED and f24d72a Merged PR 10536: REDACTED
  INFO [05/20/21 13:39:27:47] End: Using mainline development mode to calculate current version (Took: 52.68ms)
  INFO [05/20/21 13:39:27:47] Begin: Creating dictionary
  INFO [05/20/21 13:39:27:48] End: Creating dictionary (Took: 6.01ms)
  INFO [05/20/21 13:39:27:48] Begin: Storing version variables to cache file E:\agent-daredevil\_work\5\s\.git\gitversion_cache\8CE33F54F11FA306A86056180974F3A478BCD8DE.yml
  INFO [05/20/21 13:39:27:52] End: Storing version variables to cache file E:\agent-daredevil\_work\5\s\.git\gitversion_cache\8CE33F54F11FA306A86056180974F3A478BCD8DE.yml (Took: 44.63ms)
Executing GenerateSetVersionMessage for 'AzurePipelines'.
Executing GenerateBuildLogOutput for 'AzurePipelines'.
{
  "Major": 2,
  "Minor": 29,
  "Patch": 11,
  "PreReleaseTag": "6",
  "PreReleaseTagWithDash": "",
  "PreReleaseLabel": "",
  "PreReleaseLabelWithDash": "",
  "PreReleaseNumber": null,
  "WeightedPreReleaseNumber": 60000,
  "BuildMetaData": null,
  "BuildMetaDataPadded": "",
  "FullBuildMetaData": "Branch.master.Sha.f24d72af940596018b89b3b772f026447a87fae4",
  "MajorMinorPatch": "2.29.11",
  "SemVer": "2.29.11",
  "LegacySemVer": "2.29.11",
  "LegacySemVerPadded": "2.29.11",
  "AssemblySemVer": "2.0.0.0",
  "AssemblySemFileVer": "2.29.11.0",
  "FullSemVer": "2.29.11",
  "InformationalVersion": "2.29.11+Branch.master.Sha.f24d72af940596018b89b3b772f026447a87fae4",
  "BranchName": "master",
  "EscapedBranchName": "master",
  "Sha": "f24d72af940596018b89b3b772f026447a87fae4",
  "ShortSha": "f24d72a",
  "NuGetVersionV2": "2.29.11",
  "NuGetVersion": "2.29.11",
  "NuGetPreReleaseTagV2": "",
  "NuGetPreReleaseTag": "",
  "VersionSourceSha": "ec6010ca0e3fb565d386c53d5b2a958cd0678faa",
  "CommitsSinceVersionSource": 6,
  "CommitsSinceVersionSourcePadded": "0006",
  "UncommittedChanges": 0,
  "CommitDate": "2021-05-20"
}

@asbjornu
Copy link
Member

asbjornu commented May 20, 2021

@DavidDeSloovere, are you sure you're not experiencing #2441? If you are, please remove next-version from GitVersion.yml and add a git tag with the same version number, on the appropriate commit.

@DavidDeSloovere
Copy link

Yes. Looks very much like it. Thanks for figuring that out.

What if the way forward to set the "next version" then? Using commit messages?
I automatically tags the commits in master/main when build has succeeded. So I don't want to manually add a tag before the build, or I need to skip the auto tagging in the build if there is already a tag.

@asbjornu
Copy link
Member

@DavidDeSloovere, next-version is a way to override what the next tag is going to be, it is not a base-version. If the version GitVersion generates for you needs to be overridden with next-version at every turn, you should look at your workflow and how GitVersion is configured, because that should not at all be necessary.

@DavidDeSloovere
Copy link

I may have miscommunicated. I don't have the need to set the next-version every time. It's only used when I want to bump major or minor. But never for patch.
This page lists all my options https://gitversion.net/docs/reference/version-increments#manually-incrementing-the-version (next-version is listed there, I'm confused)

@asbjornu
Copy link
Member

@DavidDeSloovere, when you want to bump major or minor, do you use next-version in order to generate unstable version numbers aligning with what the next git tag is going to be, or do you use it as a replacement for git tag for stable version numbers? If you do the latter, please stop using next-version and start using git tag instead.

@asbjornu asbjornu added question and removed bug labels Sep 3, 2021
@asbjornu
Copy link
Member

asbjornu commented Sep 3, 2021

Closing as answered. Please reopen if you have more questions.

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

No branches or pull requests

4 participants