Skip to content

Commit 2c47502

Browse files
author
Yannis Guedel
committed
changed branches
1 parent ab38fd3 commit 2c47502

File tree

8 files changed

+72
-49
lines changed

8 files changed

+72
-49
lines changed

GitVersionCore.Tests/ConfigProviderTests.cs

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -30,37 +30,39 @@ public void CanReadDocument()
3030
next-version: 2.0.0
3131
tag-prefix: '[vV|version-]'
3232
mode: ContinuousDelivery
33-
develop:
34-
mode: ContinuousDeployment
35-
tag: dev
36-
release*:
37-
mode: ContinuousDeployment
38-
tag: rc
33+
branches:
34+
develop:
35+
mode: ContinuousDeployment
36+
tag: dev
37+
release[/-]:
38+
mode: ContinuousDeployment
39+
tag: rc
3940
";
4041
SetupConfigFileContent(text);
4142

4243
var config = ConfigurationProvider.Provide(gitDirectory, fileSystem);
4344
config.AssemblyVersioningScheme.ShouldBe(AssemblyVersioningScheme.MajorMinor);
4445
config.NextVersion.ShouldBe("2.0.0");
4546
config.TagPrefix.ShouldBe("[vV|version-]");
46-
config.Release.VersioningMode.ShouldBe(VersioningMode.ContinuousDeployment);
47-
config.Develop.VersioningMode.ShouldBe(VersioningMode.ContinuousDeployment);
4847
config.VersioningMode.ShouldBe(VersioningMode.ContinuousDelivery);
49-
config.Release.Tag.ShouldBe("rc");
50-
config.Develop.Tag.ShouldBe("dev");
48+
config.Branches["develop"].Tag.ShouldBe("dev");
49+
config.Branches["release[/-]"].Tag.ShouldBe("rc");
50+
config.Branches["release[/-]"].VersioningMode.ShouldBe(VersioningMode.ContinuousDeployment);
51+
config.Branches["develop"].VersioningMode.ShouldBe(VersioningMode.ContinuousDeployment);
5152
}
5253

5354
[Test]
5455
public void CanInheritVersioningMode()
5556
{
5657
const string text = @"
5758
mode: ContinuousDelivery
58-
develop:
59-
mode: ContinuousDeployment
59+
branches:
60+
develop:
61+
mode: ContinuousDeployment
6062
";
6163
SetupConfigFileContent(text);
6264
var config = ConfigurationProvider.Provide(gitDirectory, fileSystem);
63-
config.Develop.VersioningMode.ShouldBe(VersioningMode.ContinuousDeployment);
65+
config.Branches["develop"].VersioningMode.ShouldBe(VersioningMode.ContinuousDeployment);
6466
config.Release.VersioningMode.ShouldBe(VersioningMode.ContinuousDelivery);
6567
}
6668

@@ -75,8 +77,8 @@ public void CanReadOldDocument()
7577
SetupConfigFileContent(text);
7678
var config = ConfigurationProvider.Provide(gitDirectory, fileSystem);
7779
config.AssemblyVersioningScheme.ShouldBe(AssemblyVersioningScheme.MajorMinor);
78-
config.Develop.Tag.ShouldBe("alpha");
79-
config.Release.Tag.ShouldBe("rc");
80+
config.Branches["develop"].Tag.ShouldBe("alpha");
81+
config.Branches["release[/-]"].Tag.ShouldBe("rc");
8082
}
8183

8284
[Test]
@@ -86,8 +88,8 @@ public void CanReadDefaultDocument()
8688
SetupConfigFileContent(text);
8789
var config = ConfigurationProvider.Provide(gitDirectory, fileSystem);
8890
config.AssemblyVersioningScheme.ShouldBe(AssemblyVersioningScheme.MajorMinorPatch);
89-
config.Develop.Tag.ShouldBe("unstable");
90-
config.Release.Tag.ShouldBe("beta");
91+
config.Branches["develop"].Tag.ShouldBe("unstable");
92+
config.Branches["release[/-]"].Tag.ShouldBe("beta");
9193
config.TagPrefix.ShouldBe("[vV]");
9294
config.NextVersion.ShouldBe(null);
9395
}
@@ -112,7 +114,7 @@ public void VerifyInit()
112114
public void VerifyAliases()
113115
{
114116
var config = typeof(Config);
115-
var propertiesMissingAlias = config.GetProperties().Where(p => p.GetCustomAttribute(typeof(YamlAliasAttribute)) == null).Select(p => p.Name);
117+
var propertiesMissingAlias = config.GetProperties().Where(p => p.GetCustomAttribute<ObsoleteAttribute>() == null).Where(p => p.GetCustomAttribute(typeof(YamlAliasAttribute)) == null).Select(p => p.Name);
116118

117119
propertiesMissingAlias.ShouldBeEmpty();
118120
}

GitVersionCore.Tests/IntegrationTests/GitFlow/DevelopScenarios.cs

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,9 @@ public void MergingReleaseBranchBackIntoDevelopWithoutMergingToMaster_DoesNotBum
3535
[Test]
3636
public void CanChangeDevelopTagViaConfig()
3737
{
38-
using (var fixture = new EmptyRepositoryFixture(new Config
39-
{
40-
Develop = {
41-
Tag = "alpha"
42-
}
43-
}))
38+
var config = new Config();
39+
config.Branches["develop"].Tag = "alpha";
40+
using (var fixture = new EmptyRepositoryFixture(config))
4441
{
4542
fixture.Repository.MakeATaggedCommit("1.0.0");
4643
fixture.Repository.CreateBranch("develop").Checkout();
@@ -51,13 +48,9 @@ public void CanChangeDevelopTagViaConfig()
5148
[Test]
5249
public void CanHandleContinuousDelivery()
5350
{
54-
using (var fixture = new EmptyRepositoryFixture(new Config
55-
{
56-
Develop =
57-
{
58-
VersioningMode = VersioningMode.ContinuousDelivery
59-
}
60-
}))
51+
var config = new Config();
52+
config.Branches["develop"].VersioningMode = VersioningMode.ContinuousDelivery;
53+
using (var fixture = new EmptyRepositoryFixture(config))
6154
{
6255
fixture.Repository.MakeATaggedCommit("1.0.0");
6356
fixture.Repository.CreateBranch("develop").Checkout();

GitVersionCore/Configuration/Config.cs

Lines changed: 37 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,23 @@
11
namespace GitVersion
22
{
33
using System;
4+
using System.Collections.Generic;
5+
using System.Linq;
46

57
using YamlDotNet.Serialization;
68

79
public class Config
810
{
911
VersioningMode versioningMode;
1012

13+
Dictionary<string, BranchConfig> branches = new Dictionary<string, BranchConfig>();
14+
1115
public Config()
1216
{
1317
AssemblyVersioningScheme = AssemblyVersioningScheme.MajorMinorPatch;
1418
TagPrefix = "[vV]";
15-
Release = new BranchConfig { Tag = "beta" };
16-
Develop = new BranchConfig { Tag = "unstable" };
19+
Branches["release[/-]"] = new BranchConfig { Tag = "beta" };
20+
Branches["develop"] = new BranchConfig { Tag = "unstable" };
1721
VersioningMode = VersioningMode.ContinuousDelivery;
1822
Develop.VersioningMode = VersioningMode.ContinuousDeployment;
1923
}
@@ -58,23 +62,46 @@ public VersioningMode VersioningMode
5862
}
5963
set
6064
{
61-
Develop.VersioningMode = value;
62-
Release.VersioningMode = value;
65+
Branches.ToList().ForEach(b => b.Value.VersioningMode = value);
6366
versioningMode = value;
6467
}
6568
}
6669

67-
[YamlAlias("develop")]
68-
public BranchConfig Develop { get; set; }
69-
70-
[YamlAlias("release*")]
71-
public BranchConfig Release { get; set; }
72-
70+
[YamlAlias("branches")]
71+
public Dictionary<string, BranchConfig> Branches
72+
{
73+
get
74+
{
75+
return branches;
76+
}
77+
set
78+
{
79+
value.ToList().ForEach(_ => branches[_.Key] = _.Value);
80+
}
81+
}
7382

7483
[YamlAlias("tag-prefix")]
7584
public string TagPrefix { get; set; }
7685

7786
[YamlAlias("next-version")]
7887
public string NextVersion { get; set; }
88+
89+
[Obsolete]
90+
public BranchConfig Develop
91+
{
92+
get
93+
{
94+
return Branches["develop"];
95+
}
96+
}
97+
98+
[Obsolete]
99+
public BranchConfig Release
100+
{
101+
get
102+
{
103+
return Branches["release[/-]"];
104+
}
105+
}
79106
}
80107
}

GitVersionCore/Configuration/ConfigReader.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,9 @@ public static void WriteSample(TextWriter writer)
2323
writer.WriteLine("# tag-prefix: '[vV|version-] # regex to match git tag prefix");
2424
writer.WriteLine("# next-version: 1.0.0");
2525
writer.WriteLine("# mode: ContinuousDelivery | ContinuousDeployment");
26-
writer.WriteLine("# release*:\n mode: ContinuousDelivery | ContinuousDeployment\n tag: rc");
27-
writer.WriteLine("# develop:\n mode: ContinuousDelivery | ContinuousDeployment\n tag: alpha");
26+
writer.WriteLine("#branches:");
27+
writer.WriteLine("# release[/-]*:\n mode: ContinuousDelivery | ContinuousDeployment\n tag: rc");
28+
writer.WriteLine("# develop:\n mode: ContinuousDelivery | ContinuousDeployment\n tag: alpha");
2829
}
2930
}
3031
}

GitVersionCore/GitFlow/BranchFinders/DevelopBasedVersionFinderBase.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ protected SemanticVersion FindVersion(
99
GitVersionContext context,
1010
BranchType branchType)
1111
{
12-
context.CurrentBranchConfig = context.Configuration.Develop;
12+
context.CurrentBranchConfig = context.Configuration.Branches["develop"];
1313
var ancestor = FindCommonAncestorWithDevelop(context.Repository, context.CurrentBranch, branchType);
1414

1515
if (!IsThereAnyCommitOnTheBranch(context.Repository, context.CurrentBranch))

GitVersionCore/GitFlow/BranchFinders/ReleaseVersionFinder.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public SemanticVersion FindVersion(GitVersionContext context)
1414

1515
var applicableTagsInDescendingOrder = context.Repository.SemVerTagsRelatedToVersion(context.Configuration, shortVersion).OrderByDescending(tag => SemanticVersion.Parse(tag.Name, context.Configuration.TagPrefix)).ToList();
1616
var numberOfCommitsSinceLastTagOrBranchPoint = BranchCommitDifferenceFinder.NumberOfCommitsSinceLastTagOrBranchPoint(context, applicableTagsInDescendingOrder, BranchType.Release, "develop");
17-
var semanticVersionPreReleaseTag = context.Configuration.Release.VersioningMode.GetInstance().GetPreReleaseTag(context, applicableTagsInDescendingOrder, numberOfCommitsSinceLastTagOrBranchPoint);
17+
var semanticVersionPreReleaseTag = context.Configuration.Branches["release[/-]"].VersioningMode.GetInstance().GetPreReleaseTag(context, applicableTagsInDescendingOrder, numberOfCommitsSinceLastTagOrBranchPoint);
1818

1919
return new SemanticVersion
2020
{

GitVersionCore/GitFlow/GitFlowVersionFinder.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,19 @@ public SemanticVersion FindVersion(GitVersionContext context)
1111

1212
if (context.CurrentBranch.IsHotfix())
1313
{
14-
context.CurrentBranchConfig = context.Configuration.Release;
14+
context.CurrentBranchConfig = context.Configuration.Branches["release[/-]"];
1515
return new HotfixVersionFinder().FindVersion(context);
1616
}
1717

1818
if (context.CurrentBranch.IsRelease())
1919
{
20-
context.CurrentBranchConfig = context.Configuration.Release;
20+
context.CurrentBranchConfig = context.Configuration.Branches["release[/-]"];
2121
return new ReleaseVersionFinder().FindVersion(context);
2222
}
2323

2424
if (context.CurrentBranch.IsDevelop())
2525
{
26-
context.CurrentBranchConfig = context.Configuration.Develop;
26+
context.CurrentBranchConfig = context.Configuration.Branches["develop"];
2727
return new DevelopVersionFinder().FindVersion(context);
2828
}
2929

GitVersionCore/GitHubFlow/OtherBranchVersionFinder.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public bool FindVersion(GitVersionContext context, out SemanticVersion semanticV
2323

2424
if (semanticVersionPreReleaseTag.Name == "release")
2525
{
26-
semanticVersionPreReleaseTag.Name = context.Configuration.Release.Tag;
26+
semanticVersionPreReleaseTag.Name = context.Configuration.Branches["release[/-]"].Tag;
2727
}
2828

2929
semanticVersion = new SemanticVersion

0 commit comments

Comments
 (0)