|
| 1 | +using GitTools.Testing; |
| 2 | +using GitVersion.Core.Tests.Helpers; |
| 3 | +using NUnit.Framework; |
| 4 | + |
| 5 | +namespace GitVersion.Core.Tests.IntegrationTests |
| 6 | +{ |
| 7 | + [TestFixture] |
| 8 | + public class GitflowScenarios : TestBase |
| 9 | + { |
| 10 | + [Test] |
| 11 | + public void GitflowComplexExample() |
| 12 | + { |
| 13 | + const string developBranch = "develop"; |
| 14 | + const string feature1Branch = "feature/f1"; |
| 15 | + const string feature2Branch = "feature/f2"; |
| 16 | + const string release1Branch = "release/1.1.0"; |
| 17 | + const string release2Branch = "release/1.2.0"; |
| 18 | + const string hotfixBranch = "hotfix/hf"; |
| 19 | + |
| 20 | + using var fixture = new BaseGitFlowRepositoryFixture("1.0.0"); |
| 21 | + fixture.AssertFullSemver("1.1.0-alpha.1"); |
| 22 | + |
| 23 | + // Feature 1 |
| 24 | + fixture.BranchTo(feature1Branch); |
| 25 | + fixture.MakeACommit("added feature 1"); |
| 26 | + fixture.AssertFullSemver("1.1.0-f1.1+2"); |
| 27 | + fixture.Checkout(developBranch); |
| 28 | + fixture.MergeNoFF(feature1Branch); |
| 29 | + fixture.Repository.Branches.Remove(fixture.Repository.Branches[feature1Branch]); |
| 30 | + fixture.AssertFullSemver("1.1.0-alpha.3"); |
| 31 | + |
| 32 | + // Release 1.1.0 |
| 33 | + fixture.BranchTo(release1Branch); |
| 34 | + fixture.MakeACommit("release stabilization"); |
| 35 | + fixture.AssertFullSemver("1.1.0-beta.1+1"); |
| 36 | + fixture.Checkout(MainBranch); |
| 37 | + fixture.MergeNoFF(release1Branch); |
| 38 | + fixture.AssertFullSemver("1.1.0+0"); |
| 39 | + fixture.ApplyTag("1.1.0"); |
| 40 | + fixture.AssertFullSemver("1.1.0"); |
| 41 | + fixture.Checkout(developBranch); |
| 42 | + fixture.MergeNoFF(release1Branch); |
| 43 | + fixture.Repository.Branches.Remove(fixture.Repository.Branches[release1Branch]); |
| 44 | + fixture.AssertFullSemver("1.2.0-alpha.2"); |
| 45 | + |
| 46 | + // Feature 2 |
| 47 | + fixture.BranchTo(feature2Branch); |
| 48 | + fixture.MakeACommit("added feature 2"); |
| 49 | + fixture.AssertFullSemver("1.2.0-f2.1+3"); |
| 50 | + fixture.Checkout(developBranch); |
| 51 | + fixture.MergeNoFF(feature2Branch); |
| 52 | + fixture.Repository.Branches.Remove(fixture.Repository.Branches[feature2Branch]); |
| 53 | + fixture.AssertFullSemver("1.2.0-alpha.4"); |
| 54 | + |
| 55 | + // Release 1.2.0 |
| 56 | + fixture.BranchTo(release2Branch); |
| 57 | + fixture.MakeACommit("release stabilization"); |
| 58 | + fixture.AssertFullSemver("1.2.0-beta.1+1"); |
| 59 | + fixture.Checkout(MainBranch); |
| 60 | + fixture.MergeNoFF(release2Branch); |
| 61 | + fixture.AssertFullSemver("1.2.0+0"); |
| 62 | + fixture.ApplyTag("1.2.0"); |
| 63 | + fixture.AssertFullSemver("1.2.0"); |
| 64 | + fixture.Checkout(developBranch); |
| 65 | + fixture.MergeNoFF(release2Branch); |
| 66 | + fixture.Repository.Branches.Remove(fixture.Repository.Branches[release2Branch]); |
| 67 | + fixture.AssertFullSemver("1.3.0-alpha.2"); |
| 68 | + |
| 69 | + // Hotfix |
| 70 | + fixture.Checkout(MainBranch); |
| 71 | + fixture.BranchTo(hotfixBranch); |
| 72 | + fixture.MakeACommit("added hotfix"); |
| 73 | + fixture.AssertFullSemver("1.2.1-beta.1+7"); |
| 74 | + fixture.Checkout(MainBranch); |
| 75 | + fixture.MergeNoFF(hotfixBranch); |
| 76 | + fixture.AssertFullSemver("1.2.1+2"); |
| 77 | + fixture.ApplyTag("1.2.1"); |
| 78 | + fixture.AssertFullSemver("1.2.1"); |
| 79 | + fixture.Checkout(developBranch); |
| 80 | + fixture.MergeNoFF(hotfixBranch); |
| 81 | + fixture.Repository.Branches.Remove(fixture.Repository.Branches[hotfixBranch]); |
| 82 | + fixture.AssertFullSemver("1.3.0-alpha.9"); |
| 83 | + } |
| 84 | + } |
| 85 | +} |
0 commit comments