-
Notifications
You must be signed in to change notification settings - Fork 652
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #950 from JakeGinnivan/MainlineDevelopmentMode
Mainline development mode
- Loading branch information
Showing
16 changed files
with
300 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file modified
BIN
+2.58 KB
(110%)
docs/git-branching-strategies/img/39f9d8b8b007c82f1f80_major-release.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# Versioning modes | ||
GitVersion has multiple modes to fit different different ways of working. | ||
|
||
|
||
## Continuous Delivery | ||
This is the default mode, GitVersion calculates the next version and will use that until that is released. For instance: | ||
|
||
- 1.1.0+5 | ||
- 1.1.0+6 | ||
- 1.1.0+7 <-- This is the artifact we release, tag the commit which created this version | ||
- 1.1.1+0 | ||
|
||
Tags are required in this mode to communicate when the release is done as it's an external manual process. | ||
|
||
## Continuous deployment | ||
Sometimes you just want the version to keep changing and continuously deploy. A good case for this is when using Octopus deploy, as you cannot publish the same version of a package into the same feed. | ||
|
||
For this mode we followed the logic in this blog post by Xavier Decoster on the issues of incrementing automatically - http://www.xavierdecoster.com/semantic-versioning-auto-incremented-nuget-package-versions | ||
|
||
As such we force a pre-release tag on all branches, this is fine for applications but can cause problems for libraries. As such this mode may or may not work for you, which leads us into a new mode in v4. Mainline development. | ||
|
||
## Mainline development | ||
Mainline development works more like the Continuous Delivery mode, except that it tells GitVersion to *infer* releases from merges and commits to `master`. | ||
|
||
This mode is great if you do not want to tag each release because you simply deploy every commit to master. The behaviour of this mode is as follows: | ||
|
||
1. Calclate a base version (likely a tag in this mode) | ||
1. Walk all commits from the base version commit | ||
1. When a merge commit is found: | ||
- Calculate increments for each direct commit on master | ||
- Calculate the increment for the branch | ||
1. Calculate increments for each remaining direct commit | ||
1. For feature branches then calculate increment for the commits so far on your feature branch. | ||
|
||
If you *do not want* GitVersion to treat a commit or a pull request as a release and increment the version you can use `+semver: none` or `+semver: skip` in a commit message to skip incrementing for that commit. | ||
|
||
Here is an example of what mainline development looks like: | ||
|
||
![Mainline mode](./img/mainline-mode.png) | ||
|
||
|
||
**WARNING:** This approach can slow down over time, we recommend to tag intermitently (maybe for minor or major releases) because then GitVersion will start the version calculation from that point. Much like a snapshot in an event sourced system. We will probably add in warnings to tag when things are slowing down. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
105 changes: 105 additions & 0 deletions
105
src/GitVersionCore.Tests/IntegrationTests/MainlineDevelopmentMode.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
using System; | ||
using System.Reflection; | ||
using System.Text; | ||
using GitTools.Testing; | ||
using GitVersion; | ||
using GitVersionCore.Tests; | ||
using LibGit2Sharp; | ||
using NUnit.Framework; | ||
|
||
public class MainlineDevelopmentMode | ||
{ | ||
private Config config = new Config | ||
{ | ||
VersioningMode = VersioningMode.Mainline | ||
}; | ||
|
||
[Test] | ||
public void MergedFeatureBranchesToMasterImpliesRelease() | ||
{ | ||
using (var fixture = new EmptyRepositoryFixture()) | ||
{ | ||
fixture.Repository.MakeACommit("1"); | ||
fixture.MakeATaggedCommit("1.0.0"); | ||
|
||
fixture.BranchTo("feature/foo", "foo"); | ||
fixture.MakeACommit("2"); | ||
fixture.AssertFullSemver(config, "1.0.1-foo.1+1"); | ||
fixture.Checkout("master"); | ||
fixture.MergeNoFF("feature/foo"); | ||
|
||
fixture.AssertFullSemver(config, "1.0.1+2"); | ||
|
||
fixture.BranchTo("feature/foo2", "foo2"); | ||
fixture.MakeACommit("3 +semver: minor"); | ||
fixture.AssertFullSemver(config, "1.1.0-foo2.1+3"); | ||
fixture.Checkout("master"); | ||
fixture.MergeNoFF("feature/foo2"); | ||
fixture.AssertFullSemver(config, "1.1.0+4"); | ||
|
||
fixture.BranchTo("feature/foo3", "foo3"); | ||
fixture.MakeACommit("4"); | ||
fixture.Checkout("master"); | ||
fixture.MergeNoFF("feature/foo3"); | ||
fixture.SequenceDiagram.NoteOver("Merge message contains '+semver: minor'", "master"); | ||
var commit = fixture.Repository.Head.Tip; | ||
// Put semver increment in merge message | ||
fixture.Repository.Commit(commit.Message + " +semver: minor", commit.Author, commit.Committer, new CommitOptions | ||
{ | ||
AmendPreviousCommit = true | ||
}); | ||
fixture.AssertFullSemver(config, "1.2.0+6"); | ||
|
||
fixture.BranchTo("feature/foo4", "foo4"); | ||
fixture.MakeACommit("5 +semver: major"); | ||
fixture.AssertFullSemver(config, "2.0.0-foo4.1+7"); | ||
fixture.Checkout("master"); | ||
fixture.MergeNoFF("feature/foo4"); | ||
fixture.AssertFullSemver(config, "2.0.0+8"); | ||
|
||
// We should evaluate any commits not included in merge commit calculations for direct commit/push or squash to merge commits | ||
fixture.MakeACommit("6 +semver: major"); | ||
fixture.AssertFullSemver(config, "3.0.0+9"); | ||
fixture.MakeACommit("7 +semver: minor"); | ||
fixture.AssertFullSemver(config, "3.1.0+10"); | ||
fixture.MakeACommit("8"); | ||
fixture.AssertFullSemver(config, "3.1.1+11"); | ||
|
||
// Finally verify that the merge commits still function properly | ||
fixture.BranchTo("feature/foo5", "foo5"); | ||
fixture.MakeACommit("9 +semver: minor"); | ||
fixture.AssertFullSemver(config, "3.2.0-foo5.1+12"); | ||
fixture.Checkout("master"); | ||
fixture.MergeNoFF("feature/foo5"); | ||
fixture.AssertFullSemver(config, "3.2.0+13"); | ||
|
||
// One more direct commit for good measure | ||
fixture.MakeACommit("10 +semver: minor"); | ||
fixture.AssertFullSemver(config, "3.3.0+14"); | ||
// And we can commit without bumping semver | ||
fixture.MakeACommit("11 +semver: none"); | ||
fixture.AssertFullSemver(config, "3.3.0+15"); | ||
Console.WriteLine(fixture.SequenceDiagram.GetDiagram()); | ||
} | ||
} | ||
// Write test which has a forward merge into a feature branch | ||
} | ||
|
||
static class CommitExtensions | ||
{ | ||
public static void MakeACommit(this RepositoryFixtureBase fixture, string commitMsg) | ||
{ | ||
fixture.Repository.MakeACommit(commitMsg); | ||
var diagramBuilder = (StringBuilder)typeof(SequenceDiagram) | ||
.GetField("_diagramBuilder", BindingFlags.Instance | BindingFlags.NonPublic) | ||
.GetValue(fixture.SequenceDiagram); | ||
Func<string, string> getParticipant = participant => (string)typeof(SequenceDiagram) | ||
.GetMethod("GetParticipant", BindingFlags.Instance | BindingFlags.NonPublic) | ||
.Invoke(fixture.SequenceDiagram, new object[] | ||
{ | ||
participant | ||
}); | ||
diagramBuilder.AppendLineFormat("{0} -> {0}: Commit '{1}'", getParticipant(fixture.Repository.Head.FriendlyName), | ||
commitMsg); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.