Skip to content

Commit 11891f3

Browse files
authored
Merge pull request #1102 from JakeGinnivan/feature-branch-does-not-pick-up-version
Feature branch does not pick up version
2 parents 595919a + b0bd709 commit 11891f3

17 files changed

+176
-52
lines changed

docs/configuration.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ branches:
163163
increment: Patch
164164
prevent-increment-of-merged-branch-version: true
165165
track-merge-target: false
166-
is-develop: false
166+
tracks-release-branches: false
167167
is-release-branch: false
168168
release:
169169
regex: releases?[/-]
@@ -172,7 +172,7 @@ branches:
172172
increment: Patch
173173
prevent-increment-of-merged-branch-version: true
174174
track-merge-target: false
175-
is-develop: false
175+
tracks-release-branches: false
176176
is-release-branch: true
177177
feature:
178178
regex: features?[/-]
@@ -181,7 +181,7 @@ branches:
181181
increment: Inherit
182182
prevent-increment-of-merged-branch-version: false
183183
track-merge-target: false
184-
is-develop: false
184+
tracks-release-branches: false
185185
is-release-branch: false
186186
pull-request:
187187
regex: (pull|pull\-requests|pr)[/-]
@@ -191,7 +191,7 @@ branches:
191191
prevent-increment-of-merged-branch-version: false
192192
tag-number-pattern: '[/-](?<number>\d+)[-/]'
193193
track-merge-target: false
194-
is-develop: false
194+
tracks-release-branches: false
195195
is-release-branch: false
196196
hotfix:
197197
regex: hotfix(es)?[/-]
@@ -200,7 +200,7 @@ branches:
200200
increment: Patch
201201
prevent-increment-of-merged-branch-version: false
202202
track-merge-target: false
203-
is-develop: false
203+
tracks-release-branches: false
204204
is-release-branch: false
205205
support:
206206
regex: support[/-]
@@ -209,7 +209,7 @@ branches:
209209
increment: Patch
210210
prevent-increment-of-merged-branch-version: true
211211
track-merge-target: false
212-
is-develop: false
212+
tracks-release-branches: false
213213
is-release-branch: false
214214
develop:
215215
regex: dev(elop)?(ment)?$
@@ -218,7 +218,7 @@ branches:
218218
increment: Minor
219219
prevent-increment-of-merged-branch-version: false
220220
track-merge-target: true
221-
is-develop: true
221+
tracks-release-branches: true
222222
is-release-branch: false
223223
```
224224

@@ -282,7 +282,7 @@ Strategy which will look for tagged merge commits directly off the current
282282
branch. For example `develop` → `release/1.0.0` → merge into `master` and tag
283283
`1.0.0`. The tag is *not* on develop, but develop should be version `1.0.0` now.
284284

285-
### is-develop
285+
### tracks-release-branches
286286
Indicates this branch config represents develop in GitFlow.
287287

288288
### is-release-branch

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ branches:
1818
prevent-increment-of-merged-branch-version: true
1919
track-merge-target: false
2020
regex: master
21-
is-develop: false
21+
tracks-release-branches: false
2222
is-release-branch: false
2323
is-mainline: true
2424
release:
@@ -28,7 +28,7 @@ branches:
2828
prevent-increment-of-merged-branch-version: true
2929
track-merge-target: false
3030
regex: releases?[/-]
31-
is-develop: false
31+
tracks-release-branches: false
3232
is-release-branch: true
3333
is-mainline: false
3434
feature:
@@ -38,7 +38,7 @@ branches:
3838
prevent-increment-of-merged-branch-version: false
3939
track-merge-target: false
4040
regex: features?[/-]
41-
is-develop: false
41+
tracks-release-branches: false
4242
is-release-branch: false
4343
is-mainline: false
4444
pull-request:
@@ -49,7 +49,7 @@ branches:
4949
tag-number-pattern: '[/-](?<number>\d+)[-/]'
5050
track-merge-target: false
5151
regex: (pull|pull\-requests|pr)[/-]
52-
is-develop: false
52+
tracks-release-branches: false
5353
is-release-branch: false
5454
is-mainline: false
5555
hotfix:
@@ -59,7 +59,7 @@ branches:
5959
prevent-increment-of-merged-branch-version: false
6060
track-merge-target: false
6161
regex: hotfix(es)?[/-]
62-
is-develop: false
62+
tracks-release-branches: false
6363
is-release-branch: false
6464
is-mainline: false
6565
support:
@@ -69,7 +69,7 @@ branches:
6969
prevent-increment-of-merged-branch-version: true
7070
track-merge-target: false
7171
regex: support[/-]
72-
is-develop: false
72+
tracks-release-branches: false
7373
is-release-branch: false
7474
is-mainline: true
7575
develop:
@@ -79,7 +79,7 @@ branches:
7979
prevent-increment-of-merged-branch-version: false
8080
track-merge-target: true
8181
regex: dev(elop)?(ment)?$
82-
is-develop: true
82+
tracks-release-branches: true
8383
is-release-branch: false
8484
is-mainline: false
8585
ignore:

src/GitVersionCore.Tests/ConfigProviderTests.cs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,4 +305,23 @@ string SetupConfigFileContent(string text, string fileName, string path)
305305

306306
return fullPath;
307307
}
308+
309+
[Test]
310+
public void WarnOnObsoleteIsDevelopBranchConfigurationSetting()
311+
{
312+
const string text = @"
313+
assembly-versioning-scheme: MajorMinorPatch
314+
branches:
315+
master:
316+
tag: beta
317+
is-develop: true";
318+
319+
OldConfigurationException exception = Should.Throw<OldConfigurationException>(() =>
320+
{
321+
LegacyConfigNotifier.Notify(new StringReader(text));
322+
});
323+
324+
var expecedMessage = string.Format("'is-develop' is deprecated, use 'track-release-branches' instead.");
325+
exception.Message.ShouldContain(expecedMessage);
326+
}
308327
}

src/GitVersionCore.Tests/IntegrationTests/FeatureBranchScenarios.cs

Lines changed: 50 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using GitVersionCore.Tests;
44
using LibGit2Sharp;
55
using NUnit.Framework;
6+
using System.Collections.Generic;
67

78
[TestFixture]
89
public class FeatureBranchScenarios
@@ -223,7 +224,7 @@ public void BranchCreatedAfterFinishReleaseShouldInheritAndIncrementFromLastMast
223224
fixture.Checkout("develop");
224225
fixture.Repository.MergeNoFF("release/0.2.0");
225226
fixture.Repository.Branches.Remove("release/2.0.0");
226-
227+
227228
fixture.Repository.MakeACommit();
228229

229230
//validate develop branch version after merging release 0.2.0 to master and develop (finish release)
@@ -237,4 +238,51 @@ public void BranchCreatedAfterFinishReleaseShouldInheritAndIncrementFromLastMast
237238
fixture.AssertFullSemver("0.3.0-TEST-1.1+2");
238239
}
239240
}
240-
}
241+
242+
[Test]
243+
public void PickUpVersionFromMasterMarkedWithIsTracksReleaseBranches()
244+
{
245+
var config = new Config
246+
{
247+
VersioningMode = VersioningMode.ContinuousDelivery,
248+
Branches = new Dictionary<string, BranchConfig>
249+
{
250+
{
251+
"master", new BranchConfig()
252+
{
253+
Tag = "pre",
254+
TracksReleaseBranches = true,
255+
}
256+
},
257+
{
258+
"release", new BranchConfig()
259+
{
260+
IsReleaseBranch = true,
261+
Tag = "rc",
262+
}
263+
}
264+
}
265+
};
266+
267+
using (var fixture = new EmptyRepositoryFixture())
268+
{
269+
fixture.MakeACommit();
270+
271+
// create a release branch and tag a release
272+
fixture.BranchTo("release/0.10.0");
273+
fixture.MakeACommit();
274+
fixture.MakeACommit();
275+
fixture.AssertFullSemver(config, "0.10.0-rc.1+2");
276+
277+
// switch to master and verify the version
278+
fixture.Checkout("master");
279+
fixture.MakeACommit();
280+
fixture.AssertFullSemver(config, "0.10.1-pre.1+1");
281+
282+
// create a feature branch from master and verify the version
283+
// TODO this will pass once default becomes inherit
284+
//fixture.BranchTo("MyFeatureD");
285+
//fixture.AssertFullSemver(config, "0.10.1-MyFeatureD.1+1");
286+
}
287+
}
288+
}

src/GitVersionCore.Tests/TestEffectiveConfiguration.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
namespace GitVersionCore.Tests
22
{
3-
using System.Collections.Generic;
4-
using System.Linq;
53
using GitVersion;
64
using GitVersion.VersionFilters;
5+
using System.Collections.Generic;
6+
using System.Linq;
77

88
public class TestEffectiveConfiguration : EffectiveConfiguration
99
{
@@ -28,15 +28,15 @@ public TestEffectiveConfiguration(
2828
int buildMetaDataPadding = 4,
2929
int commitsSinceVersionSourcePadding = 4,
3030
IEnumerable<IVersionFilter> versionFilters = null,
31-
bool isDevelop = false,
32-
bool isRelease = false) :
31+
bool tracksReleaseBranches = false,
32+
bool isRelease = false) :
3333
base(assemblyVersioningScheme, assemblyInformationalFormat, versioningMode, gitTagPrefix, tag, nextVersion, IncrementStrategy.Patch,
3434
branchPrefixToTrim, preventIncrementForMergedBranchVersion, tagNumberPattern, continuousDeploymentFallbackTag,
3535
trackMergeTarget,
3636
majorMessage, minorMessage, patchMessage, noBumpMessage,
3737
commitMessageMode, legacySemVerPadding, buildMetaDataPadding, commitsSinceVersionSourcePadding,
3838
versionFilters ?? Enumerable.Empty<IVersionFilter>(),
39-
isDevelop, isRelease)
39+
tracksReleaseBranches, isRelease)
4040
{
4141
}
4242
}

src/GitVersionCore/BranchConfigurationCalculator.cs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
namespace GitVersion
22
{
3+
using JetBrains.Annotations;
4+
using LibGit2Sharp;
35
using System;
46
using System.Collections.Generic;
57
using System.Linq;
68
using System.Text.RegularExpressions;
79

8-
using JetBrains.Annotations;
9-
10-
using LibGit2Sharp;
11-
1210
public class BranchConfigurationCalculator
1311
{
1412
public static KeyValuePair<string, BranchConfig> GetBranchConfiguration(Commit currentCommit, IRepository repository, bool onlyEvaluateTrackedBranches, Config config, Branch currentBranch, IList<Branch> excludedInheritBranches = null)
@@ -48,7 +46,7 @@ static KeyValuePair<string, BranchConfig>[] LookupBranchConfiguration([NotNull]
4846
{
4947
throw new ArgumentNullException("config");
5048
}
51-
49+
5250
if (currentBranch == null)
5351
{
5452
throw new ArgumentNullException("currentBranch");
@@ -120,7 +118,7 @@ static KeyValuePair<string, BranchConfig> InheritBranchConfiguration(bool onlyEv
120118
Increment = branchConfig.Increment,
121119
PreventIncrementOfMergedBranchVersion = branchConfig.PreventIncrementOfMergedBranchVersion,
122120
// If we are inheriting from develop then we should behave like develop
123-
IsDevelop = branchConfig.IsDevelop
121+
TracksReleaseBranches = branchConfig.TracksReleaseBranches
124122
});
125123
}
126124

@@ -152,7 +150,7 @@ static KeyValuePair<string, BranchConfig> InheritBranchConfiguration(bool onlyEv
152150
Increment = inheritingBranchConfig.Increment,
153151
PreventIncrementOfMergedBranchVersion = inheritingBranchConfig.PreventIncrementOfMergedBranchVersion,
154152
// If we are inheriting from develop then we should behave like develop
155-
IsDevelop = inheritingBranchConfig.IsDevelop
153+
TracksReleaseBranches = inheritingBranchConfig.TracksReleaseBranches
156154
});
157155
}
158156
}

src/GitVersionCore/Configuration/BranchConfig.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public BranchConfig(BranchConfig branchConfiguration)
1818
TagNumberPattern = branchConfiguration.TagNumberPattern;
1919
TrackMergeTarget = branchConfiguration.TrackMergeTarget;
2020
CommitMessageIncrementing = branchConfiguration.CommitMessageIncrementing;
21-
IsDevelop = branchConfiguration.IsDevelop;
21+
TracksReleaseBranches = branchConfiguration.TracksReleaseBranches;
2222
IsReleaseBranch = branchConfiguration.IsReleaseBranch;
2323
IsMainline = branchConfiguration.IsMainline;
2424
}
@@ -43,15 +43,15 @@ public BranchConfig(BranchConfig branchConfiguration)
4343

4444
[YamlMember(Alias = "track-merge-target")]
4545
public bool? TrackMergeTarget { get; set; }
46-
46+
4747
[YamlMember(Alias = "commit-message-incrementing")]
4848
public CommitMessageIncrementMode? CommitMessageIncrementing { get; set; }
4949

5050
[YamlMember(Alias = "regex")]
5151
public string Regex { get; set; }
5252

53-
[YamlMember(Alias = "is-develop")]
54-
public bool? IsDevelop { get; set; }
53+
[YamlMember(Alias = "tracks-release-branches")]
54+
public bool? TracksReleaseBranches { get; set; }
5555

5656
[YamlMember(Alias = "is-release-branch")]
5757
public bool? IsReleaseBranch { get; set; }

src/GitVersionCore/Configuration/Config.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,11 @@ public Config()
3333
[YamlMember(Alias = "next-version")]
3434
public string NextVersion
3535
{
36-
get { return this.nextVersion; }
36+
get { return nextVersion; }
3737
set
3838
{
3939
int major;
40-
this.nextVersion = int.TryParse(value, NumberStyles.Any, NumberFormatInfo.InvariantInfo, out major)
40+
nextVersion = int.TryParse(value, NumberStyles.Any, NumberFormatInfo.InvariantInfo, out major)
4141
? string.Format("{0}.0", major)
4242
: value;
4343
}

src/GitVersionCore/Configuration/ConfigurationProvider.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ namespace GitVersion
22
{
33
using Configuration.Init.Wizard;
44
using GitVersion.Helpers;
5+
using System;
56
using System.IO;
67
using System.Linq;
78
using System.Text;
@@ -121,10 +122,10 @@ public static void ApplyDefaultsTo(Config config)
121122
defaultIncrementStrategy: IncrementStrategy.Minor,
122123
defaultVersioningMode: VersioningMode.ContinuousDeployment,
123124
defaultTrackMergeTarget: true,
124-
isDevelop: true);
125+
tracksReleaseBranches: true);
125126

126127
// Any user defined branches should have other values defaulted after known branches filled in
127-
// This allows users to override one value of
128+
// This allows users to override one value of
128129
foreach (var branchConfig in configBranches)
129130
{
130131
var regex = branchConfig.Value.Regex;
@@ -163,7 +164,7 @@ public static void ApplyBranchDefaults(Config config,
163164
VersioningMode? defaultVersioningMode = null, // Looked up from main config
164165
bool defaultTrackMergeTarget = false,
165166
string defaultTagNumberPattern = null,
166-
bool isDevelop = false,
167+
bool tracksReleaseBranches = false,
167168
bool isReleaseBranch = false,
168169
bool isMainline = false)
169170
{
@@ -174,7 +175,7 @@ public static void ApplyBranchDefaults(Config config,
174175
branchConfig.PreventIncrementOfMergedBranchVersion = branchConfig.PreventIncrementOfMergedBranchVersion ?? defaultPreventIncrement;
175176
branchConfig.TrackMergeTarget = branchConfig.TrackMergeTarget ?? defaultTrackMergeTarget;
176177
branchConfig.VersioningMode = branchConfig.VersioningMode ?? defaultVersioningMode ?? config.VersioningMode;
177-
branchConfig.IsDevelop = branchConfig.IsDevelop ?? isDevelop;
178+
branchConfig.TracksReleaseBranches = branchConfig.TracksReleaseBranches ?? tracksReleaseBranches;
178179
branchConfig.IsReleaseBranch = branchConfig.IsReleaseBranch ?? isReleaseBranch;
179180
branchConfig.IsMainline = branchConfig.IsMainline ?? isMainline;
180181
}

0 commit comments

Comments
 (0)