Skip to content

Commit e1f3576

Browse files
authored
Merge pull request #832 from JakeGinnivan/BumpDevelopWhenReleaseBranchCreated
Bump develop when release branch created
2 parents 35c696a + 3f6bc9e commit e1f3576

39 files changed

+437
-213
lines changed

GitVersion.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,6 @@
11
assembly-versioning-scheme: MajorMinorPatch
2-
next-version: 3.4.0
2+
branches:
3+
master:
4+
tag: beta
5+
ignore:
6+
sha: []

docs/configuration.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@ The global configuration options are:
4848
- **`sha:`** A sequence of SHAs to be excluded from the version calculations. Useful when there is a rogue commit in history yielding a bad version.
4949
- **`commits-before:`** Allows to setup an exclusion range. Effectively any commit < `commits-before` will be ignored.
5050

51+
- **`is-develop:`** Indicates this branch config represents develop in GitFlow
52+
53+
**`is-release-branch:`** Indicates this branch config represents a release branch in GitFlow
54+
5155
## Branch configuration
5256

5357
Then we have branch specific configuration, which looks something like this:
Loading
Loading
Loading
Loading
Loading
Loading
Loading

src/GitVersionCore.Tests/ConfigProviderTests.CanWriteOutEffectiveConfiguration.approved.txt

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,42 +16,56 @@ branches:
1616
increment: Patch
1717
prevent-increment-of-merged-branch-version: true
1818
track-merge-target: false
19+
is-develop: false
20+
is-release-branch: false
1921
releases?[/-]:
2022
mode: ContinuousDelivery
2123
tag: beta
2224
increment: Patch
2325
prevent-increment-of-merged-branch-version: true
2426
track-merge-target: false
27+
is-develop: false
28+
is-release-branch: true
2529
features?[/-]:
2630
mode: ContinuousDelivery
2731
tag: useBranchName
2832
increment: Inherit
2933
prevent-increment-of-merged-branch-version: false
3034
track-merge-target: false
35+
is-develop: false
36+
is-release-branch: false
3137
(pull|pull\-requests|pr)[/-]:
3238
mode: ContinuousDelivery
3339
tag: PullRequest
3440
increment: Inherit
3541
prevent-increment-of-merged-branch-version: false
3642
tag-number-pattern: '[/-](?<number>\d+)[-/]'
3743
track-merge-target: false
44+
is-develop: false
45+
is-release-branch: false
3846
hotfix(es)?[/-]:
3947
mode: ContinuousDelivery
4048
tag: beta
4149
increment: Patch
4250
prevent-increment-of-merged-branch-version: false
4351
track-merge-target: false
52+
is-develop: false
53+
is-release-branch: false
4454
support[/-]:
4555
mode: ContinuousDelivery
4656
tag: ''
4757
increment: Patch
4858
prevent-increment-of-merged-branch-version: true
4959
track-merge-target: false
60+
is-develop: false
61+
is-release-branch: false
5062
dev(elop)?(ment)?$:
5163
mode: ContinuousDeployment
52-
tag: unstable
64+
tag: alpha
5365
increment: Minor
5466
prevent-increment-of-merged-branch-version: false
5567
track-merge-target: true
68+
is-develop: true
69+
is-release-branch: false
5670
ignore:
5771
sha: []

src/GitVersionCore.Tests/ConfigProviderTests.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ public void CanReadDefaultDocument()
216216
var config = ConfigurationProvider.Provide(repoPath, fileSystem);
217217
config.AssemblyVersioningScheme.ShouldBe(AssemblyVersioningScheme.MajorMinorPatch);
218218
config.AssemblyInformationalFormat.ShouldBe(null);
219-
config.Branches["dev(elop)?(ment)?$"].Tag.ShouldBe("unstable");
219+
config.Branches["dev(elop)?(ment)?$"].Tag.ShouldBe("alpha");
220220
config.Branches["releases?[/-]"].Tag.ShouldBe("beta");
221221
config.TagPrefix.ShouldBe(ConfigurationProvider.DefaultTagPrefix);
222222
config.NextVersion.ShouldBe(null);
@@ -242,10 +242,10 @@ public void WarnOnExistingGitVersionConfigYamlFile(string path)
242242

243243
var logOutput = string.Empty;
244244
Action<string> action = info => { logOutput = info; };
245-
Logger.SetLoggers(action, action, action);
246-
247-
ConfigurationProvider.Verify(workingPath, repoPath, fileSystem);
248-
245+
using (Logger.AddLoggersTemporarily(action, action, action))
246+
{
247+
ConfigurationProvider.Verify(workingPath, repoPath, fileSystem);
248+
}
249249
var configFileDeprecatedWarning = string.Format("{0}' is deprecated, use '{1}' instead", ConfigurationProvider.ObsoleteConfigFileName, ConfigurationProvider.DefaultConfigFileName);
250250
logOutput.Contains(configFileDeprecatedWarning).ShouldBe(true);
251251
}
@@ -289,10 +289,10 @@ public void NoWarnOnGitVersionYmlFile()
289289

290290
var s = string.Empty;
291291
Action<string> action = info => { s = info; };
292-
Logger.SetLoggers(action, action, action);
293-
294-
ConfigurationProvider.Provide(repoPath, fileSystem);
295-
292+
using (Logger.AddLoggersTemporarily(action, action, action))
293+
{
294+
ConfigurationProvider.Provide(repoPath, fileSystem);
295+
}
296296
s.Length.ShouldBe(0);
297297
}
298298

src/GitVersionCore.Tests/ExecuteCoreTests.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -200,12 +200,10 @@ string RepositoryScope(ExecuteCore executeCore = null, Action<EmptyRepositoryFix
200200
Action<string> infoLogger = s =>
201201
{
202202
infoBuilder.AppendLine(s);
203-
Console.WriteLine(s);
204203
};
205204
executeCore = executeCore ?? new ExecuteCore(fileSystem);
206205

207-
Logger.SetLoggers(infoLogger, Console.WriteLine, Console.WriteLine);
208-
206+
using (Logger.AddLoggersTemporarily(infoLogger, s => {}, s => { }))
209207
using (var fixture = new EmptyRepositoryFixture())
210208
{
211209
fixture.Repository.MakeACommit();

src/GitVersionCore.Tests/GitToolsTestingExtensions.cs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,13 @@ public static Config ApplyDefaults(this Config config)
1515
return config;
1616
}
1717

18-
public static VersionVariables GetVersion(this RepositoryFixtureBase fixture, Config configuration, IRepository repository = null, string commitId = null, bool isForTrackedBranchOnly = true)
18+
public static VersionVariables GetVersion(this RepositoryFixtureBase fixture, Config configuration = null, IRepository repository = null, string commitId = null, bool isForTrackedBranchOnly = true)
1919
{
20-
ConfigurationProvider.ApplyDefaultsTo(configuration);
20+
if (configuration == null)
21+
{
22+
configuration = new Config();
23+
ConfigurationProvider.ApplyDefaultsTo(configuration);
24+
}
2125
var gitVersionContext = new GitVersionContext(repository ?? fixture.Repository, configuration, isForTrackedBranchOnly, commitId);
2226
var executeGitVersion = ExecuteGitVersion(gitVersionContext);
2327
var variables = VariableProvider.GetVariablesFor(executeGitVersion, gitVersionContext.Configuration, gitVersionContext.IsCurrentCommitTagged);
@@ -55,7 +59,7 @@ public static void AssertFullSemver(this RepositoryFixtureBase fixture, Config c
5559
}
5660
if (commitId == null)
5761
{
58-
fixture.SequenceDiagram.NoteOver(fullSemver, fixture.Repository.Head.FriendlyName, color: "#D3D3D3");
62+
fixture.SequenceDiagram.NoteOver(fullSemver, fixture.Repository.Head.FriendlyName, color: "#D3D3D3");
5963
}
6064
}
6165

@@ -70,7 +74,7 @@ static SemanticVersion ExecuteGitVersion(GitVersionContext context)
7074
/// </summary>
7175
public static void InitialiseRepo(this RemoteRepositoryFixture fixture)
7276
{
73-
// TODO !!new GitPreparer(null, null, new Authentication(), false, fixture.LocalRepositoryFixture.RepositoryPath).Initialise(true, null);
77+
new GitPreparer(null, null, new Authentication(), false, fixture.LocalRepositoryFixture.RepositoryPath).Initialise(true, null);
7478
}
7579
}
7680
}

src/GitVersionCore.Tests/IntegrationTests/DevelopScenarios.cs

Lines changed: 32 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public void WhenDevelopHasMultipleCommits_SpecifyExistingCommitId()
2121
fixture.Repository.MakeACommit();
2222
fixture.Repository.MakeACommit();
2323

24-
fixture.AssertFullSemver("1.1.0-unstable.3", commitId: thirdCommit.Sha);
24+
fixture.AssertFullSemver("1.1.0-alpha.3", commitId: thirdCommit.Sha);
2525
}
2626
}
2727

@@ -39,7 +39,7 @@ public void WhenDevelopHasMultipleCommits_SpecifyNonExistingCommitId()
3939
fixture.Repository.MakeACommit();
4040
fixture.Repository.MakeACommit();
4141

42-
fixture.AssertFullSemver("1.1.0-unstable.5", commitId: "nonexistingcommitid");
42+
fixture.AssertFullSemver("1.1.0-alpha.5", commitId: "nonexistingcommitid");
4343
}
4444
}
4545

@@ -61,10 +61,11 @@ public void CanChangeDevelopTagViaConfig()
6161
{
6262
Branches =
6363
{
64-
{"dev(elop)?(ment)?$", new BranchConfig
6564
{
66-
Tag = "alpha"
67-
}
65+
"dev(elop)?(ment)?$", new BranchConfig
66+
{
67+
Tag = "alpha"
68+
}
6869
}
6970
}
7071
};
@@ -97,7 +98,7 @@ public void WhenDevelopBranchedFromMaster_MinorIsIncreased()
9798
fixture.Repository.MakeATaggedCommit("1.0.0");
9899
fixture.Repository.Checkout(fixture.Repository.CreateBranch("develop"));
99100
fixture.Repository.MakeACommit();
100-
fixture.AssertFullSemver("1.1.0-unstable.1");
101+
fixture.AssertFullSemver("1.1.0-alpha.1");
101102
}
102103
}
103104

@@ -116,7 +117,7 @@ public void MergingReleaseBranchBackIntoDevelopWithMergingToMaster_DoesBumpDevel
116117

117118
fixture.Repository.Checkout("develop");
118119
fixture.Repository.MergeNoFF("release-2.0.0", Generate.SignatureNow());
119-
fixture.AssertFullSemver("2.1.0-unstable.0");
120+
fixture.AssertFullSemver("2.1.0-alpha.2");
120121
}
121122
}
122123

@@ -154,7 +155,30 @@ public void WhenDevelopBranchedFromMasterDetachedHead_MinorIsIncreased()
154155
var commit = fixture.Repository.Head.Tip;
155156
fixture.Repository.MakeACommit();
156157
fixture.Repository.Checkout(commit);
157-
fixture.AssertFullSemver("1.1.0-unstable.1");
158+
fixture.AssertFullSemver("1.1.0-alpha.1");
159+
}
160+
}
161+
162+
[Test]
163+
public void InheritVersionFromReleaseBranch()
164+
{
165+
using (var fixture = new EmptyRepositoryFixture())
166+
{
167+
fixture.MakeATaggedCommit("1.0.0");
168+
fixture.BranchTo("develop");
169+
fixture.MakeACommit();
170+
fixture.BranchTo("release/2.0.0");
171+
fixture.MakeACommit();
172+
fixture.MakeACommit();
173+
fixture.Checkout("develop");
174+
fixture.AssertFullSemver("2.1.0-alpha.0");
175+
fixture.MakeACommit();
176+
fixture.AssertFullSemver("2.1.0-alpha.1");
177+
fixture.MergeNoFF("release/2.0.0");
178+
fixture.AssertFullSemver("2.1.0-alpha.4");
179+
fixture.BranchTo("feature/MyFeature");
180+
fixture.MakeACommit();
181+
fixture.AssertFullSemver("2.1.0-MyFeature.1+3");
158182
}
159183
}
160184
}

src/GitVersionCore.Tests/IntegrationTests/DocumentationSamples.cs

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
using GitTools;
1+
using System;
2+
using GitTools;
23
using GitTools.Testing;
3-
using GitVersion;
44
using GitVersionCore.Tests;
55
using NUnit.Framework;
66
using Shouldly;
@@ -23,7 +23,7 @@ public void GitFlowFeatureBranch()
2323

2424
// Branch to develop
2525
fixture.MakeACommit();
26-
fixture.AssertFullSemver("1.3.0-unstable.1");
26+
fixture.AssertFullSemver("1.3.0-alpha.1");
2727

2828
// Open Pull Request
2929
fixture.BranchTo("feature/myfeature", "feature");
@@ -38,7 +38,8 @@ public void GitFlowFeatureBranch()
3838
fixture.SequenceDiagram.Destroy("feature/myfeature");
3939
fixture.SequenceDiagram.NoteOver("Feature branches should\r\n" +
4040
"be deleted once merged", "feature/myfeature");
41-
fixture.AssertFullSemver("1.3.0-unstable.3");
41+
fixture.AssertFullSemver("1.3.0-alpha.3");
42+
Console.WriteLine(fixture.SequenceDiagram.GetDiagram());
4243
}
4344
}
4445

@@ -57,7 +58,7 @@ public void GitFlowPullRequestBranch()
5758

5859
// Branch to develop
5960
fixture.MakeACommit();
60-
fixture.AssertFullSemver("1.3.0-unstable.1");
61+
fixture.AssertFullSemver("1.3.0-alpha.1");
6162

6263
// Open Pull Request
6364
fixture.BranchTo("pull/2/merge", "pr");
@@ -72,7 +73,8 @@ public void GitFlowPullRequestBranch()
7273
fixture.SequenceDiagram.Destroy("pull/2/merge");
7374
fixture.SequenceDiagram.NoteOver("Feature branches/pr's should\r\n" +
7475
"be deleted once merged", "pull/2/merge");
75-
fixture.AssertFullSemver("1.3.0-unstable.3");
76+
fixture.AssertFullSemver("1.3.0-alpha.3");
77+
Console.WriteLine(fixture.SequenceDiagram.GetDiagram());
7678
}
7779
}
7880

@@ -103,6 +105,7 @@ public void GitFlowHotfixBranch()
103105
fixture.SequenceDiagram.Destroy("hotfix/1.2.1");
104106
fixture.SequenceDiagram.NoteOver("Hotfix branches are deleted once merged", "hotfix/1.2.1");
105107
fixture.ApplyTag("1.2.1");
108+
Console.WriteLine(fixture.SequenceDiagram.GetDiagram());
106109
}
107110
}
108111

@@ -130,7 +133,7 @@ public void GitFlowMinorRelease()
130133
// Make another commit on develop
131134
fixture.Checkout("develop");
132135
fixture.MakeACommit();
133-
fixture.AssertFullSemver("1.3.0-unstable.2");
136+
fixture.AssertFullSemver("1.4.0-alpha.1");
134137

135138
// Make a commit to release-1.3.0
136139
fixture.Checkout("release/1.3.0");
@@ -159,7 +162,8 @@ public void GitFlowMinorRelease()
159162

160163
// Not 0 for commit count as we can't know the increment rules of the merged branch
161164
fixture.Checkout("develop");
162-
fixture.AssertFullSemver("1.4.0-unstable.2");
165+
fixture.AssertFullSemver("1.4.0-alpha.4");
166+
Console.WriteLine(fixture.SequenceDiagram.GetDiagram());
163167
}
164168
}
165169

@@ -186,7 +190,7 @@ public void GitFlowMajorRelease()
186190
// Make another commit on develop
187191
fixture.Checkout("develop");
188192
fixture.MakeACommit();
189-
fixture.AssertFullSemver("1.4.0-unstable.2");
193+
fixture.AssertFullSemver("2.1.0-alpha.1");
190194

191195
// Make a commit to release-2.0.0
192196
fixture.Checkout("release/2.0.0");
@@ -216,7 +220,8 @@ public void GitFlowMajorRelease()
216220

217221
// Not 0 for commit count as we can't know the increment rules of the merged branch
218222
fixture.Checkout("develop");
219-
fixture.AssertFullSemver("2.1.0-unstable.2");
223+
fixture.AssertFullSemver("2.1.0-alpha.4");
224+
Console.WriteLine(fixture.SequenceDiagram.GetDiagram());
220225
}
221226
}
222227

@@ -260,6 +265,7 @@ public void GitFlowSupportHotfixRelease()
260265
fixture.AssertFullSemver("1.3.1+4");
261266
fixture.ApplyTag("1.3.1");
262267
fixture.AssertFullSemver("1.3.1");
268+
Console.WriteLine(fixture.SequenceDiagram.GetDiagram());
263269
}
264270
}
265271

@@ -304,6 +310,7 @@ public void GitFlowSupportMinorRelease()
304310
fixture.AssertFullSemver("1.4.0+0");
305311
fixture.ApplyTag("1.4.0");
306312
fixture.AssertFullSemver("1.4.0");
313+
Console.WriteLine(fixture.SequenceDiagram.GetDiagram());
307314
}
308315
}
309316

@@ -395,7 +402,7 @@ public void GitHubFlowMajorRelease()
395402
fixture.AssertFullSemver("2.0.0-beta.1");
396403

397404
// test that the CommitsSinceVersionSource should still return commit count
398-
var version = fixture.GetVersion(new Config());
405+
var version = fixture.GetVersion();
399406
version.CommitsSinceVersionSource.ShouldBe("2");
400407

401408
// Make a commit after a tag should bump up the beta

0 commit comments

Comments
 (0)