Skip to content

Commit 11d48a7

Browse files
committed
Bump develop when release branch is created
- Fixed an commit counting bug - Based on discussion at #632 - Fixes #695 - Updated related docs
1 parent 35c696a commit 11d48a7

25 files changed

+276
-108
lines changed

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:
-139 Bytes
Loading
-358 Bytes
Loading

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

Lines changed: 14 additions & 0 deletions
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
5264
tag: unstable
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: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -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: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ static SemanticVersion ExecuteGitVersion(GitVersionContext context)
7070
/// </summary>
7171
public static void InitialiseRepo(this RemoteRepositoryFixture fixture)
7272
{
73-
// TODO !!new GitPreparer(null, null, new Authentication(), false, fixture.LocalRepositoryFixture.RepositoryPath).Initialise(true, null);
73+
new GitPreparer(null, null, new Authentication(), false, fixture.LocalRepositoryFixture.RepositoryPath).Initialise(true, null);
7474
}
7575
}
7676
}

src/GitVersionCore.Tests/IntegrationTests/DevelopScenarios.cs

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -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
};
@@ -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-unstable.2");
120121
}
121122
}
122123

@@ -157,4 +158,27 @@ public void WhenDevelopBranchedFromMasterDetachedHead_MinorIsIncreased()
157158
fixture.AssertFullSemver("1.1.0-unstable.1");
158159
}
159160
}
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-unstable.0");
175+
fixture.MakeACommit();
176+
fixture.AssertFullSemver("2.1.0-unstable.1");
177+
fixture.MergeNoFF("release/2.0.0");
178+
fixture.AssertFullSemver("2.1.0-unstable.4");
179+
fixture.BranchTo("feature/MyFeature");
180+
fixture.MakeACommit();
181+
fixture.AssertFullSemver("2.1.0-MyFeature.1+1");
182+
}
183+
}
160184
}

src/GitVersionCore.Tests/IntegrationTests/DocumentationSamples.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ public void GitFlowMinorRelease()
130130
// Make another commit on develop
131131
fixture.Checkout("develop");
132132
fixture.MakeACommit();
133-
fixture.AssertFullSemver("1.3.0-unstable.2");
133+
fixture.AssertFullSemver("1.4.0-unstable.1");
134134

135135
// Make a commit to release-1.3.0
136136
fixture.Checkout("release/1.3.0");
@@ -159,7 +159,7 @@ public void GitFlowMinorRelease()
159159

160160
// Not 0 for commit count as we can't know the increment rules of the merged branch
161161
fixture.Checkout("develop");
162-
fixture.AssertFullSemver("1.4.0-unstable.2");
162+
fixture.AssertFullSemver("1.4.0-unstable.4");
163163
}
164164
}
165165

@@ -186,7 +186,7 @@ public void GitFlowMajorRelease()
186186
// Make another commit on develop
187187
fixture.Checkout("develop");
188188
fixture.MakeACommit();
189-
fixture.AssertFullSemver("1.4.0-unstable.2");
189+
fixture.AssertFullSemver("2.1.0-unstable.1");
190190

191191
// Make a commit to release-2.0.0
192192
fixture.Checkout("release/2.0.0");
@@ -216,7 +216,7 @@ public void GitFlowMajorRelease()
216216

217217
// Not 0 for commit count as we can't know the increment rules of the merged branch
218218
fixture.Checkout("develop");
219-
fixture.AssertFullSemver("2.1.0-unstable.2");
219+
fixture.AssertFullSemver("2.1.0-unstable.4");
220220
}
221221
}
222222

src/GitVersionCore.Tests/IntegrationTests/ReleaseBranchScenarios.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public void NoMergeBacksToDevelopInCaseThereAreChangesInReleaseBranch()
4848
// Merge to develop
4949
fixture.Repository.Checkout("develop");
5050
fixture.Repository.MergeNoFF("release/1.0.0");
51-
fixture.AssertFullSemver("1.1.0-unstable.1");
51+
fixture.AssertFullSemver("1.1.0-unstable.2");
5252

5353
fixture.Repository.MakeACommit();
5454
fixture.Repository.Branches.Remove(releaseBranch);
@@ -226,7 +226,7 @@ public void WhenReleaseBranchIsMergedIntoDevelopHighestVersionIsTakenWithIt()
226226
fixture.Repository.Checkout("develop");
227227
fixture.Repository.MergeNoFF("release-1.0.0", Generate.SignatureNow());
228228

229-
fixture.AssertFullSemver("2.1.0-unstable.5");
229+
fixture.AssertFullSemver("2.1.0-unstable.6");
230230
}
231231
}
232232

0 commit comments

Comments
 (0)