Skip to content

Commit d40baaa

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 ce9ef68 commit d40baaa

29 files changed

+280
-120
lines changed

docs/configuration.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@ The global configuration options are:
4646
- **`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.
4747
- **`commits-before:`** Allows to setup an exclusion range. Effectively any commit < `commits-before` will be ignored.
4848

49+
- **`is-develop:`** Indicates this branch config represents develop in GitFlow
50+
51+
**`is-release-branch:`** Indicates this branch config represents a release branch in GitFlow
52+
4953
## Branch configuration
5054

5155
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: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ public void CanProvideConfigForNewBranch()
112112
tag: bugfix";
113113
SetupConfigFileContent(text);
114114
var config = ConfigurationProvider.Provide(repoPath, fileSystem);
115-
115+
116116
config.Branches["bug[/-]"].Tag.ShouldBe("bugfix");
117117
}
118118

@@ -145,7 +145,7 @@ public void NextVersionCanHavePatch()
145145

146146
config.NextVersion.ShouldBe("2.12.654651698");
147147
}
148-
148+
149149
[Test]
150150
[Category("NoMono")]
151151
[Description("Won't run on Mono due to source information not being available for ShouldMatchApproved.")]
@@ -235,10 +235,10 @@ public void WarnOnExistingGitVersionConfigYamlFile()
235235

236236
var s = string.Empty;
237237
Action<string> action = info => { s = info; };
238-
Logger.SetLoggers(action, action, action);
239-
240-
ConfigurationProvider.Provide(repoPath, fileSystem);
241-
238+
using (Logger.AddLoggersTemporarily(action, action, action))
239+
{
240+
ConfigurationProvider.Provide(repoPath, fileSystem);
241+
}
242242
s.Contains("'GitVersionConfig.yaml' is deprecated, use 'GitVersion.yml' instead.").ShouldBe(true);
243243
}
244244

@@ -249,10 +249,10 @@ public void NoWarnOnGitVersionYmlFile()
249249

250250
var s = string.Empty;
251251
Action<string> action = info => { s = info; };
252-
Logger.SetLoggers(action, action, action);
253-
254-
ConfigurationProvider.Provide(repoPath, fileSystem);
255-
252+
using (Logger.AddLoggersTemporarily(action, action, action))
253+
{
254+
ConfigurationProvider.Provide(repoPath, fileSystem);
255+
}
256256
s.Length.ShouldBe(0);
257257
}
258258

src/GitVersionCore.Tests/ExecuteCoreTests.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -147,12 +147,10 @@ string RepositoryScope(ExecuteCore executeCore = null, Action<EmptyRepositoryFix
147147
Action<string> infoLogger = s =>
148148
{
149149
infoBuilder.AppendLine(s);
150-
Console.WriteLine(s);
151150
};
152151
executeCore = executeCore ?? new ExecuteCore(fileSystem);
153152

154-
Logger.SetLoggers(infoLogger, Console.WriteLine, Console.WriteLine);
155-
153+
using (Logger.AddLoggersTemporarily(infoLogger, s => {}, s => { }))
156154
using (var fixture = new EmptyRepositoryFixture())
157155
{
158156
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)