Skip to content

Allow use of features and hotfixes with mainline mode #2480

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

Merged
merged 3 commits into from
Dec 29, 2020

Conversation

andyfurniss4
Copy link

@andyfurniss4 andyfurniss4 commented Dec 16, 2020

See #2479 for detailed description of issue.

This PR allows the use of feature/hotfix branch pre-release builds when using mainline mode. Previously this was throwing an exception with message "Mainline development mode doesn't yet support pre-release tags on master". This would occur after the following steps:

  • master has 1.0.0
  • feature branch from master
  • commit to feature branch -> 1.1.0-alpha.1 (correct)
  • merge feature into master -> Exception "Mainline development mode doesn't yet support pre-release tags on master" as it's trying to tag master with 1.1.0-alpha.2 rather than 1.1.0.

Description

After getting the base versions in BaseVersionCalculator.GetBaseVersion(), check if the configured versioning mode is mainline, if it is then filter out pre-release versions from baseVersions list before proceeding.

Related Issue

#2479

Motivation and Context

I'm trying to achieve the following:

Versioning NuGet packages using GitVersion. I do not intend to use develop or release branches because it's just overkill for me and my team and would frankly just be a waste of time and effort.

We want to be able to use master as our released branch. Versions on the master branch will always be format {major}.{minor}.{patch}. We would like to use feature branches for new functionality and would like feature branches to also trigger package builds but of a pre-release format such as {major}.{minor}.{patch}-{tag}.{number}. Feature branches merged into master would increment the minor version automatically. Finally, we would like to use hotfix branches for bug fixes. Hotfixes builds would have the same pre-release format as feature branches but when they're merged into master, they'd increment the patch version.

I have tried using both Mainline and Continuous Deployment modes to achieve this but both have failed me so far. I might just be doing something wrong so please advise as to whether this is possible and how.

The documentation shows that my desired outcome should indeed be possible with mainline mode, however this does not seem to be the case in reality.

The documentation contains a graphic which begins like this:

image

Firstly, this shows that a feature branch has been tagged with 1.0.1-foo.1+1. The current mainline functionality creates a tag with name 1.0.1-foo.1 (missing the +1). Is this documentation just old? Has the +1 part been removed now?

Secondly, the diagram shows that once the feature branch is merged into master, master is then tagged with 1.0.1 (same issue with +2). This is not the case, GitVersion outputs version 1.0.1-foo.2 for me.

How Has This Been Tested?

Added new tests to cover new scenarios and also ensured all existing tests still pass successfully.

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@asbjornu
Copy link
Member

Firstly, this shows that a feature branch has been tagged with 1.0.1-foo.1+1.

It's not a git tag, it's the resulting version number from running GitVersion that yields 1.0.1-foo.1+1.

The current mainline functionality creates a tag with name 1.0.1-foo.1 (missing the +1). Is this documentation just old? Has the +1 part been removed now?

The +1 part is the build metadata. More on that here.

Secondly, the diagram shows that once the feature branch is merged into master, master is then tagged with 1.0.1 (same issue with +2). This is not the case, GitVersion outputs version 1.0.1-foo.2 for me.

I agree that sounds wrong and I think the changes made by you look fine. There's 3 tests failing, though, which we need to figure out before merging. I've tried re-running them, but there's no reaction from AzDO yet.

@arturcic arturcic force-pushed the feature/features-in-mainline branch from e5986db to 839b6ec Compare December 29, 2020 07:40
@arturcic arturcic linked an issue Dec 29, 2020 that may be closed by this pull request
@arturcic
Copy link
Member

@asbjornu I rebased the PR on top of master, now build passes

@asbjornu asbjornu modified the milestone: 5.6.1 Dec 29, 2020
@asbjornu asbjornu merged commit 8f8cca1 into GitTools:master Dec 29, 2020
@asbjornu
Copy link
Member

Thank you for your contributions, @andyfurniss4! 🙏🏼

@andyfurniss4
Copy link
Author

Brilliant, thanks for finishing this up for me guys. I'm glad it's all working and accepted!

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

Successfully merging this pull request may close these issues.

[Bug] Mainline with feature branches throws exception
3 participants