Skip to content

Incorrect increment when merging feature branch into master. #1689

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

Closed
mchippingtonderrick-afl opened this issue May 24, 2019 · 3 comments
Closed

Comments

@mchippingtonderrick-afl

When merging a feature branch into Master, GitVersion is incrementing the patch number, rather than the minor version number. The minor version number is correctly incremented when evaluated in-branch, but when merged into Master, it only increments the patch version, as if it was just a commit to master, rather than a merge.

Customised GitVersion.yml for reference:

mode: ContinuousDelivery
branches:
  master:
    regex: master
    tag: ''
    increment: Patch
  patch:
    regex: '(patch|bugfix|fix)[/-]'
    tag: useBranchName
    increment: Patch
    source-branches: ['master', 'major', 'minor']
  minor:
    regex: '(minor|feature)[/-]'
    tag: useBranchName
    increment: Minor
    source-branches: ['master', 'major']
  major:
    regex: '(major|breaking)[/-]'
    tag: useBranchName
    increment: Major
    source-branches: ['master']

Other potentially relevant information:
Merge is via merging a pull-request on GitHub.
GitVersion is being used in AzurePipelines triggered on commits, using the GitVersion add-in for it.
Example git history graph for clarity:

* - Master - v1.4.6 (calculated, should be v1.5.0)
|\
| * - Feature - v1.5.0-prerelease+2 (calculated)
| * - Feature - v1.5.0-prerelease+1 (calculated)
|/
* - Master - v1.4.5 - (tagged)

Any suggestions for what I must be doing wrong here, and how I can make it behave the way I would like it to?

@mchippingtonderrick-afl
Copy link
Author

mchippingtonderrick-afl commented Jun 12, 2019

Setting the increment for Master to "Inherit" makes it behave correctly in the above situation.
However, I've run into another issue, where it uses an unmerged, and unrelated branch for determining the version increment.

* - Master - v2.0.0 (calculated, should be v1.5.0)
|\
| * - Feature - v1.5.0-prerelease+2 (calculated)
| * - Feature - v1.5.0-prerelease+1 (calculated)
| | * - Major - v2.0.0-prerelease+1 (calculated)
| |/
|/
* - Master - v1.4.5 - (tagged)

These branches both share the same base commit, but I don't see how or why that should cause this.

Relevant segment of the log for reference:

INFO [06/12/19 14:36:38:28] IsDynamicGitRepository: False
INFO [06/12/19 14:36:38:28] Returning Project Root from DotGitDirectory: d:\a\1\s\.git - d:\a\1\s
INFO [06/12/19 14:36:38:28] Project root is: d:\a\1\s
INFO [06/12/19 14:36:38:28] DotGit directory is: d:\a\1\s\.git
INFO [06/12/19 14:36:38:30] IsDynamicGitRepository: False
INFO [06/12/19 14:36:38:30] Returning Project Root from DotGitDirectory: d:\a\1\s\.git - d:\a\1\s
INFO [06/12/19 14:36:38:30] Begin: Loading version variables from disk cache
  INFO [06/12/19 14:36:38:30] Cache file d:\a\1\s\.git\gitversion_cache\1C5CBCF94CD15F6CC3FE1E4190FB6FC73FA2874D.yml not found.
INFO [06/12/19 14:36:38:30] End: Loading version variables from disk cache (Took: 0.00ms)
INFO [06/12/19 14:36:38:30] IsDynamicGitRepository: False
INFO [06/12/19 14:36:38:30] Returning Project Root from DotGitDirectory: d:\a\1\s\.git - d:\a\1\s
INFO [06/12/19 14:36:38:48] Using latest commit on specified branch
INFO [06/12/19 14:36:38:50] Begin: Attempting to inherit branch configuration from parent branch
  INFO [06/12/19 14:36:38:52] HEAD is merge commit, this is likely a pull request using feature/mirror-pipeline-changes as base
  INFO [06/12/19 14:36:38:52] Begin: Finding branch source of 'feature/mirror-pipeline-changes'
    INFO [06/12/19 14:36:38:57] Begin: Finding merge base between 'feature/mirror-pipeline-changes' and 'major/LP-11'.
      INFO [06/12/19 14:36:38:59] Found merge base of 875696d171e4732d7057499c28c9474daf090c31
      INFO [06/12/19 14:36:38:59] Merge base of feature/mirror-pipeline-changes' and 'major/LP-11 is 875696d171e4732d7057499c28c9474daf090c31
    INFO [06/12/19 14:36:38:59] End: Finding merge base between 'feature/mirror-pipeline-changes' and 'major/LP-11'. (Took: 15.48ms)
    INFO [06/12/19 14:36:38:59] Begin: Finding merge base between 'feature/mirror-pipeline-changes' and 'origin/major/LP-11'.
      INFO [06/12/19 14:36:38:59] Found merge base of 875696d171e4732d7057499c28c9474daf090c31
      INFO [06/12/19 14:36:38:59] Merge base of feature/mirror-pipeline-changes' and 'origin/major/LP-11 is 875696d171e4732d7057499c28c9474daf090c31
    INFO [06/12/19 14:36:38:59] End: Finding merge base between 'feature/mirror-pipeline-changes' and 'origin/major/LP-11'. (Took: 0.00ms)
    INFO [06/12/19 14:36:38:60] Multiple source branches have been found, picking the first one (major/LP-11).
This may result in incorrect commit counting.
Options were:
 major/LP-11, origin/major/LP-11
  INFO [06/12/19 14:36:38:60] End: Finding branch source of 'feature/mirror-pipeline-changes' (Took: 87.64ms)
  INFO [06/12/19 14:36:38:60] Begin: Getting branches containing the commit '875696d171e4732d7057499c28c9474daf090c31'.
    INFO [06/12/19 14:36:38:60] Trying to find direct branches.
    INFO [06/12/19 14:36:38:60] No direct branches found, searching through tracked branches.
    INFO [06/12/19 14:36:38:62] Searching for commits reachable from 'origin/major/LP-11'.
    INFO [06/12/19 14:36:38:62] The branch 'origin/major/LP-11' has a matching commit.
  INFO [06/12/19 14:36:38:62] End: Getting branches containing the commit '875696d171e4732d7057499c28c9474daf090c31'. (Took: 15.62ms)
  INFO [06/12/19 14:36:38:62] Found possible parent branches: origin/major/LP-11
INFO [06/12/19 14:36:38:62] End: Attempting to inherit branch configuration from parent branch (Took: 118.82ms)
INFO [06/12/19 14:36:38:62] Running against branch: master (2b6eed08f42f9e2f55f68adb8493b22d4ced338b)

@mchippingtonderrick-afl
Copy link
Author

mchippingtonderrick-afl commented Jun 25, 2019

I'd forgotten to post it here, but I have had some further issues with this configuration.

I've tried trimming the set of source-branches to just 'master' on the other branches, so that it wouldn't try to use the wrong branch in the above scenario, however, it gets stuck in an infinite loop of trying to find the increment to inherit, failing to do so, defaulting to using master's increment, and needing to find the increment to inherit again.

I have also tried using Mainline which from what I understand is supposed to be the way to achieve what I'm trying to do here, but I have so far not been able to get it to work correctly.

Honestly, at this point I only really want to know how to configure GitVersion so that creating a feature / patch branch from master, and merging it back in will increment the appropriate version number for the branch. It really shouldn't be complicated to do, and yet nothing that I've tried has actually worked.

@mchippingtonderrick-afl
Copy link
Author

Closing since the linked issue is bound to be more helpful / relevant.

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

No branches or pull requests

1 participant