Skip to content

Commit dae1636

Browse files
committed
OverrideConfiguration only if it has been specified. remove default null values in implementing ConfigurationProvider.
1 parent 5e878c6 commit dae1636

File tree

4 files changed

+10
-9
lines changed

4 files changed

+10
-9
lines changed

src/GitVersion.Core.Tests/Extensions/GitToolsTestingExtensions.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,6 @@ public static IBranch CreateMockBranch(string name, params ICommit[] commits)
5555

5656
public static VersionVariables GetVersion(this RepositoryFixtureBase fixture, GitVersionConfiguration? configuration = null, IRepository? repository = null, string? commitId = null, bool onlyTrackedBranches = true, string? branch = null)
5757
{
58-
configuration ??= new ConfigurationBuilder().Build();
59-
6058
repository ??= fixture.Repository;
6159

6260
var options = Options.Create(new GitVersionOptions

src/GitVersion.Core/Configuration/ConfigurationProvider.cs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public ConfigurationProvider(IFileSystem fileSystem, ILog log, IConfigurationFil
2525
this.repositoryInfo = repositoryInfo.NotNull();
2626
}
2727

28-
public GitVersionConfiguration Provide(GitVersionConfiguration? overrideConfiguration = null)
28+
public GitVersionConfiguration Provide(GitVersionConfiguration? overrideConfiguration)
2929
{
3030
var gitVersionOptions = this.options.Value;
3131
var workingDirectory = gitVersionOptions.WorkingDirectory;
@@ -35,14 +35,17 @@ public GitVersionConfiguration Provide(GitVersionConfiguration? overrideConfigur
3535
return Provide(rootDirectory, overrideConfiguration);
3636
}
3737

38-
public GitVersionConfiguration Provide(string? workingDirectory, GitVersionConfiguration? overrideConfiguration = null)
38+
public GitVersionConfiguration Provide(string? workingDirectory, GitVersionConfiguration? overrideConfiguration)
3939
{
4040
var configurationBuilder = new ConfigurationBuilder();
41+
4142
if (workingDirectory != null)
4243
configurationBuilder = configurationBuilder.Add(this.configFileLocator.ReadConfig(workingDirectory));
43-
return configurationBuilder
44-
.Add(overrideConfiguration ?? new GitVersionConfiguration())
45-
.Build();
44+
45+
if (overrideConfiguration != null)
46+
configurationBuilder.Add(overrideConfiguration);
47+
48+
return configurationBuilder.Build();
4649
}
4750

4851
public void Init(string workingDirectory)

src/GitVersion.Core/PublicAPI.Shipped.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -231,8 +231,8 @@ GitVersion.Configuration.ConfigurationModule.RegisterTypes(Microsoft.Extensions.
231231
GitVersion.Configuration.ConfigurationProvider
232232
GitVersion.Configuration.ConfigurationProvider.ConfigurationProvider(GitVersion.IFileSystem! fileSystem, GitVersion.Logging.ILog! log, GitVersion.Configuration.IConfigurationFileLocator! configFileLocator, Microsoft.Extensions.Options.IOptions<GitVersion.GitVersionOptions!>! options, GitVersion.Configuration.Init.Wizard.IConfigInitWizard! configInitWizard, GitVersion.IGitRepositoryInfo! repositoryInfo) -> void
233233
GitVersion.Configuration.ConfigurationProvider.Init(string! workingDirectory) -> void
234-
GitVersion.Configuration.ConfigurationProvider.Provide(GitVersion.Configuration.GitVersionConfiguration? overrideConfiguration = null) -> GitVersion.Configuration.GitVersionConfiguration!
235-
GitVersion.Configuration.ConfigurationProvider.Provide(string? workingDirectory, GitVersion.Configuration.GitVersionConfiguration? overrideConfiguration = null) -> GitVersion.Configuration.GitVersionConfiguration!
234+
GitVersion.Configuration.ConfigurationProvider.Provide(GitVersion.Configuration.GitVersionConfiguration? overrideConfiguration) -> GitVersion.Configuration.GitVersionConfiguration!
235+
GitVersion.Configuration.ConfigurationProvider.Provide(string? workingDirectory, GitVersion.Configuration.GitVersionConfiguration? overrideConfiguration) -> GitVersion.Configuration.GitVersionConfiguration!
236236
GitVersion.Configuration.ConfigurationSerializer
237237
GitVersion.Configuration.ConfigurationSerializer.ConfigurationSerializer() -> void
238238
GitVersion.Configuration.EffectiveBranchConfiguration

0 commit comments

Comments
 (0)