Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 68 additions & 0 deletions src/GitVersionCore.Tests/ConfigProviderTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using NUnit.Framework;
using Shouldly;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
Expand Down Expand Up @@ -362,4 +363,71 @@ public void WarnOnObsoleteIsDevelopBranchConfigurationSetting()
const string expectedMessage = @"'is-develop' is deprecated, use 'tracks-release-branches' instead.";
exception.Message.ShouldContain(expectedMessage);
}

[Test]
public void ShouldUseSpecifiedSourceBranchesForDevelop()
{
var defaultConfig = ConfigurationProvider.Provide(repoPath, fileSystem);
const string text = @"
next-version: 2.0.0
branches:
develop:
mode: ContinuousDeployment
source-branches: ['develop']
tag: dev";
SetupConfigFileContent(text);
var config = ConfigurationProvider.Provide(repoPath, fileSystem);

config.Branches["develop"].SourceBranches.ShouldBe(new List<string> { "develop" });
}

[Test]
public void ShouldUseDefaultSourceBranchesWhenNotSpecifiedForDevelop()
{
var defaultConfig = ConfigurationProvider.Provide(repoPath, fileSystem);
const string text = @"
next-version: 2.0.0
branches:
develop:
mode: ContinuousDeployment
tag: dev";
SetupConfigFileContent(text);
var config = ConfigurationProvider.Provide(repoPath, fileSystem);

config.Branches["develop"].SourceBranches.ShouldBe(new List<string>());
}

[Test]
public void ShouldUseSpecifiedSourceBranchesForFeature()
{
var defaultConfig = ConfigurationProvider.Provide(repoPath, fileSystem);
const string text = @"
next-version: 2.0.0
branches:
feature:
mode: ContinuousDeployment
source-branches: ['develop', 'release']
tag: dev";
SetupConfigFileContent(text);
var config = ConfigurationProvider.Provide(repoPath, fileSystem);

config.Branches["feature"].SourceBranches.ShouldBe(new List<string> { "develop", "release" });
}

[Test]
public void ShouldUseDefaultSourceBranchesWhenNotSpecifiedForFeature()
{
var defaultConfig = ConfigurationProvider.Provide(repoPath, fileSystem);
const string text = @"
next-version: 2.0.0
branches:
feature:
mode: ContinuousDeployment
tag: dev";
SetupConfigFileContent(text);
var config = ConfigurationProvider.Provide(repoPath, fileSystem);

config.Branches["feature"].SourceBranches.ShouldBe(
new List<string> { "develop", "master", "release", "feature", "support", "hotfix" });
}
}
3 changes: 2 additions & 1 deletion src/GitVersionCore/Configuration/ConfigurationProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,8 @@ public static void ApplyBranchDefaults(Config config,
bool isMainline = false)
{
branchConfig.Regex = string.IsNullOrEmpty(branchConfig.Regex) ? branchRegex : branchConfig.Regex;
branchConfig.SourceBranches = sourceBranches;
branchConfig.SourceBranches = branchConfig.SourceBranches == null || !branchConfig.SourceBranches.Any()
? sourceBranches : branchConfig.SourceBranches;
branchConfig.Tag = branchConfig.Tag ?? defaultTag;
branchConfig.TagNumberPattern = branchConfig.TagNumberPattern ?? defaultTagNumberPattern;
branchConfig.Increment = branchConfig.Increment ?? defaultIncrementStrategy ?? config.Increment ?? DefaultIncrementStrategy;
Expand Down