Skip to content

Commit c2330e4

Browse files
author
Yannis Guedel
committed
enhanced branches config
1 parent 2c47502 commit c2330e4

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

GitVersionCore.Tests/ConfigProviderTests.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ public void CanInheritVersioningMode()
6464
var config = ConfigurationProvider.Provide(gitDirectory, fileSystem);
6565
config.Branches["develop"].VersioningMode.ShouldBe(VersioningMode.ContinuousDeployment);
6666
config.Release.VersioningMode.ShouldBe(VersioningMode.ContinuousDelivery);
67+
config.Develop.Tag.ShouldBe("unstable");
6768
}
6869

6970
[Test]

GitVersionCore/Configuration/Config.cs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,21 @@ public Dictionary<string, BranchConfig> Branches
7676
}
7777
set
7878
{
79-
value.ToList().ForEach(_ => branches[_.Key] = _.Value);
79+
value.ToList().ForEach(_ => branches[_.Key] = MergeObjects(branches[_.Key], _.Value));
8080
}
8181
}
8282

83+
private T MergeObjects<T>(T target, T source)
84+
{
85+
typeof(T).GetProperties()
86+
.Where(prop => prop.CanRead && prop.CanWrite)
87+
.Select(_ => new {prop = _, value =_.GetValue(source, null) } )
88+
.Where(_ => _.value != null)
89+
.ToList()
90+
.ForEach(_ => _.prop.SetValue(target, _.value, null));
91+
return target;
92+
}
93+
8394
[YamlAlias("tag-prefix")]
8495
public string TagPrefix { get; set; }
8596

0 commit comments

Comments
 (0)