Skip to content

Commit 981bf8e

Browse files
committed
Throw when mainline is configured explicitly on a branch
This should help prevent confusion seen in #932
1 parent bff50ab commit 981bf8e

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/GitVersionCore/Configuration/ConfigurationProvider.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
namespace GitVersion
22
{
3+
using System;
34
using GitVersion.Configuration.Init.Wizard;
45
using GitVersion.Helpers;
56
using System.ComponentModel;
@@ -43,13 +44,28 @@ public static string SelectConfigFilePath(GitPreparer gitPreparer, IFileSystem f
4344
public static Config Provide(string workingDirectory, IFileSystem fileSystem, bool applyDefaults = true, Config overrideConfig = null)
4445
{
4546
var readConfig = ReadConfig(workingDirectory, fileSystem);
47+
VerifyConfiguration(readConfig);
48+
4649
if (applyDefaults)
4750
ApplyDefaultsTo(readConfig);
4851
if (null != overrideConfig)
4952
ApplyOverridesTo(readConfig, overrideConfig);
5053
return readConfig;
5154
}
5255

56+
static void VerifyConfiguration(Config readConfig)
57+
{
58+
// Verify no branches are set to mainline mode
59+
if (readConfig.Branches.Any(b => b.Value.VersioningMode == VersioningMode.Mainline))
60+
{
61+
throw new Exception(@"Mainline mode only works at the repository level, a single branch cannot be put into mainline mode
62+
63+
This is because mainline mode treats your entire git repository as an event source with each merge into the 'mainline' incrementing the version.
64+
65+
If the docs do not help you decide on the mode open an issue to discuss what you are trying to do.");
66+
}
67+
}
68+
5369
public static void ApplyDefaultsTo(Config config)
5470
{
5571
MigrateBranches(config);

0 commit comments

Comments
 (0)