Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/3101 rename config to configuration #3226

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
052be4e
Rename the class Config to Configuration. Change name space from GitV…
HHobeck Oct 12, 2022
d52cb30
Rename the class BranchConfig to BranchConfiguration. Change paramete…
HHobeck Oct 12, 2022
de55192
dotnet-format .\src\ --exclude **/AddFormats/
HHobeck Oct 12, 2022
487b0f2
add using GitVersion.Model.Configurations in ArgumentParserTests class
HHobeck Oct 12, 2022
16d5005
Change Configuration to GitVersionConfiguration and change namespace …
HHobeck Oct 12, 2022
746efd9
Model.Configuration.GitVersionConfiguration -> GitVersionConfiguration
HHobeck Oct 12, 2022
b88d3cb
Rename ConfigFileLocator to ConfigurationFileLocator.
HHobeck Oct 12, 2022
8f1803a
Rename ConfigProvider to ConfigurationProvider
HHobeck Oct 12, 2022
fcdd1c1
Rename ConfigExtensions to ConfigurationExtensions
HHobeck Oct 12, 2022
ea8dd26
Rename ConfigSerializer to ConfigurationSerializer
HHobeck Oct 12, 2022
5c19a4c
Rename IgnoreConfig to IgnoreConfiguration
HHobeck Oct 12, 2022
9377a66
Move BranchConfiguration, EffectiveBranchConfiguration, EffectiveConf…
HHobeck Oct 12, 2022
5755513
Rename OverrideConfigOptionParser to OverrideConfigurationOptionParser
HHobeck Oct 13, 2022
ddc43c1
Rename ConfigExtensionsTests to ConfigurationExtensionsTests
HHobeck Oct 13, 2022
2b28a43
Rename ConfigProviderTests to ConfigurationProviderTests
HHobeck Oct 13, 2022
7462dc6
Rename ConfigFileLocatorTests to ConfigurationFileLocatorTests
HHobeck Oct 13, 2022
5e878c6
Rename IgnoreConfigTests to IgnoreConfigurationTests
HHobeck Oct 13, 2022
dae1636
OverrideConfiguration only if it has been specified. remove default n…
HHobeck Oct 13, 2022
9446385
Rename variable configProvider to configurationProvider
HHobeck Oct 13, 2022
ec543ff
Move AssemblyFileVersioningScheme and AssemblyVersioningScheme to sep…
HHobeck Oct 14, 2022
57aaae1
Move classes from GitVersion.Core.Model to the dedicated namespace fo…
HHobeck Oct 14, 2022
711107a
Create GitFlowConfigurationBuilder and ScratchConfigurationBuilder cl…
HHobeck Oct 14, 2022
e0a89ef
dotnet-format .\src\ --exclude **/AddFormats/
HHobeck Oct 14, 2022
bb4887f
Merge branch 'main' into feature/3101_rename-config-to-configuration
HHobeck Oct 14, 2022
e18d34d
Remove TestConfigurationBuilder and crate GitFlow and GitHubFlowConfi…
HHobeck Oct 15, 2022
767fabd
FinalizeConfiguration and ValidateConfiguration in TestConfigurationB…
HHobeck Oct 15, 2022
5fca00b
Merge branch 'main' into feature/3101_rename-config-to-configuration
HHobeck Oct 16, 2022
3f213f3
Rename ShAs to Shas IgnoreConfiguration class.
HHobeck Oct 17, 2022
973759e
Merge branch 'main' into feature/3101_rename-config-to-configuration
HHobeck Oct 17, 2022
56bca3c
Minor update nuget packages to the current version.
HHobeck Oct 17, 2022
dc94627
Revert "Minor update nuget packages to the current version."
HHobeck Oct 17, 2022
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
49 changes: 24 additions & 25 deletions src/GitVersion.App.Tests/ArgumentParserTests.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
using GitTools.Testing;
using GitVersion.Configuration;
using GitVersion.Core.Tests.Helpers;
using GitVersion.Extensions;
using GitVersion.Helpers;
using GitVersion.Logging;
using GitVersion.Model;
using GitVersion.Model.Configuration;
using GitVersion.VersionCalculation;
using Microsoft.Extensions.DependencyInjection;
using NUnit.Framework;
Expand Down Expand Up @@ -410,7 +409,7 @@ private static IEnumerable<TestCaseData> OverrideconfigWithInvalidOptionTestData
}

[TestCaseSource(nameof(OverrideConfigWithSingleOptionTestData))]
public void OverrideConfigWithSingleOptions(string options, Config expected)
public void OverrideConfigWithSingleOptions(string options, GitVersionConfiguration expected)
{
var arguments = this.argumentParser.ParseArguments($"/overrideconfig {options}");
arguments.OverrideConfig.ShouldBeEquivalentTo(expected);
Expand All @@ -420,134 +419,134 @@ private static IEnumerable<TestCaseData> OverrideConfigWithSingleOptionTestData(
{
yield return new TestCaseData(
"assembly-versioning-scheme=MajorMinor",
new Config
new GitVersionConfiguration
{
AssemblyVersioningScheme = AssemblyVersioningScheme.MajorMinor
}
);
yield return new TestCaseData(
"assembly-file-versioning-scheme=\"MajorMinorPatch\"",
new Config
new GitVersionConfiguration
{
AssemblyFileVersioningScheme = AssemblyFileVersioningScheme.MajorMinorPatch
}
);
yield return new TestCaseData(
"assembly-informational-format=\"{Major}.{Minor}.{Patch}.{env:CI_JOB_ID ?? 0}\"",
new Config
new GitVersionConfiguration
{
AssemblyInformationalFormat = "{Major}.{Minor}.{Patch}.{env:CI_JOB_ID ?? 0}"
}
);
yield return new TestCaseData(
"assembly-versioning-format=\"{Major}.{Minor}.{Patch}.{env:CI_JOB_ID ?? 0}\"",
new Config
new GitVersionConfiguration
{
AssemblyVersioningFormat = "{Major}.{Minor}.{Patch}.{env:CI_JOB_ID ?? 0}"
}
);
yield return new TestCaseData(
"assembly-file-versioning-format=\"{Major}.{Minor}.{Patch}.{env:CI_JOB_ID ?? 0}\"",
new Config
new GitVersionConfiguration
{
AssemblyFileVersioningFormat = "{Major}.{Minor}.{Patch}.{env:CI_JOB_ID ?? 0}"
}
);
yield return new TestCaseData(
"mode=ContinuousDelivery",
new Config
new GitVersionConfiguration
{
VersioningMode = VersioningMode.ContinuousDelivery
}
);
yield return new TestCaseData(
"tag-prefix=sample",
new Config
new GitVersionConfiguration
{
TagPrefix = "sample"
}
);
yield return new TestCaseData(
"continuous-delivery-fallback-tag=cd-tag",
new Config
new GitVersionConfiguration
{
ContinuousDeploymentFallbackTag = "cd-tag"
}
);
yield return new TestCaseData(
"next-version=1",
new Config
new GitVersionConfiguration
{
NextVersion = "1"
}
);
yield return new TestCaseData(
"major-version-bump-message=\"This is major version bump message.\"",
new Config
new GitVersionConfiguration
{
MajorVersionBumpMessage = "This is major version bump message."
}
);
yield return new TestCaseData(
"minor-version-bump-message=\"This is minor version bump message.\"",
new Config
new GitVersionConfiguration
{
MinorVersionBumpMessage = "This is minor version bump message."
}
);
yield return new TestCaseData(
"patch-version-bump-message=\"This is patch version bump message.\"",
new Config
new GitVersionConfiguration
{
PatchVersionBumpMessage = "This is patch version bump message."
}
);
yield return new TestCaseData(
"no-bump-message=\"This is no bump message.\"",
new Config
new GitVersionConfiguration
{
NoBumpMessage = "This is no bump message."
}
);
yield return new TestCaseData(
"tag-pre-release-weight=2",
new Config
new GitVersionConfiguration
{
TagPreReleaseWeight = 2
}
);
yield return new TestCaseData(
"commit-message-incrementing=MergeMessageOnly",
new Config
new GitVersionConfiguration
{
CommitMessageIncrementing = CommitMessageIncrementMode.MergeMessageOnly
}
);
yield return new TestCaseData(
"increment=Minor",
new Config
new GitVersionConfiguration
{
Increment = IncrementStrategy.Minor
}
);
yield return new TestCaseData(
"commit-date-format=\"MM/dd/yyyy h:mm tt\"",
new Config
new GitVersionConfiguration
{
CommitDateFormat = "MM/dd/yyyy h:mm tt"
}
);
yield return new TestCaseData(
"update-build-number=true",
new Config
new GitVersionConfiguration
{
UpdateBuildNumber = true
}
);
}

[TestCaseSource(nameof(OverrideconfigWithMultipleOptionsTestData))]
public void OverrideconfigWithMultipleOptions(string options, Config expected)
public void OverrideconfigWithMultipleOptions(string options, GitVersionConfiguration expected)
{
var arguments = this.argumentParser.ParseArguments(options);
arguments.OverrideConfig.ShouldBeEquivalentTo(expected);
Expand All @@ -557,23 +556,23 @@ private static IEnumerable<TestCaseData> OverrideconfigWithMultipleOptionsTestDa
{
yield return new TestCaseData(
"/overrideconfig tag-prefix=sample /overrideconfig assembly-versioning-scheme=MajorMinor",
new Config
new GitVersionConfiguration
{
TagPrefix = "sample",
AssemblyVersioningScheme = AssemblyVersioningScheme.MajorMinor
}
);
yield return new TestCaseData(
"/overrideconfig tag-prefix=sample /overrideconfig assembly-versioning-format=\"{Major}.{Minor}.{Patch}.{env:CI_JOB_ID ?? 0}\"",
new Config
new GitVersionConfiguration
{
TagPrefix = "sample",
AssemblyVersioningFormat = "{Major}.{Minor}.{Patch}.{env:CI_JOB_ID ?? 0}"
}
);
yield return new TestCaseData(
"/overrideconfig tag-prefix=sample /overrideconfig assembly-versioning-format=\"{Major}.{Minor}.{Patch}.{env:CI_JOB_ID ?? 0}\" /overrideconfig update-build-number=true /overrideconfig assembly-versioning-scheme=MajorMinorPatchTag /overrideconfig mode=ContinuousDelivery /overrideconfig tag-pre-release-weight=4",
new Config
new GitVersionConfiguration
{
TagPrefix = "sample",
AssemblyVersioningFormat = "{Major}.{Minor}.{Patch}.{env:CI_JOB_ID ?? 0}",
Expand Down
5 changes: 2 additions & 3 deletions src/GitVersion.App/ArgumentParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using GitVersion.Extensions;
using GitVersion.Helpers;
using GitVersion.Logging;
using GitVersion.Model;
using GitVersion.OutputVariables;

namespace GitVersion;
Expand Down Expand Up @@ -420,7 +419,7 @@ private static void ParseOverrideConfig(Arguments arguments, IReadOnlyCollection
if (values == null || values.Count == 0)
return;

var parser = new OverrideConfigOptionParser();
var parser = new OverrideConfigurationOptionParser();

// key=value
foreach (var keyValueOption in values)
Expand All @@ -432,7 +431,7 @@ private static void ParseOverrideConfig(Arguments arguments, IReadOnlyCollection
}

var optionKey = keyAndValue[0].ToLowerInvariant();
if (!OverrideConfigOptionParser.SupportedProperties.Contains(optionKey))
if (!OverrideConfigurationOptionParser.SupportedProperties.Contains(optionKey))
{
throw new WarningException($"Could not parse /overrideconfig option: {keyValueOption}. Unsupported 'key'.");
}
Expand Down
5 changes: 2 additions & 3 deletions src/GitVersion.App/Arguments.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using GitVersion.Configuration;
using GitVersion.Logging;
using GitVersion.Model;
using GitVersion.Model.Configuration;

namespace GitVersion;

Expand All @@ -9,7 +8,7 @@ public class Arguments
public AuthenticationInfo Authentication = new();

public string? ConfigFile;
public Config? OverrideConfig;
public GitVersionConfiguration? OverrideConfig;
public bool ShowConfig;

public string? TargetPath;
Expand Down
17 changes: 8 additions & 9 deletions src/GitVersion.App/GitVersionExecutor.cs
Original file line number Diff line number Diff line change
@@ -1,31 +1,30 @@
using GitVersion.Configuration;
using GitVersion.Extensions;
using GitVersion.Logging;
using GitVersion.Model;

namespace GitVersion;

public class GitVersionExecutor : IGitVersionExecutor
{
private readonly ILog log;
private readonly IConsole console;
private readonly IConfigFileLocator configFileLocator;
private readonly IConfigurationFileLocator configFileLocator;
private readonly IHelpWriter helpWriter;
private readonly IGitRepositoryInfo repositoryInfo;
private readonly IConfigProvider configProvider;
private readonly IConfigurationProvider configurationProvider;
private readonly IGitVersionCalculateTool gitVersionCalculateTool;
private readonly IGitVersionOutputTool gitVersionOutputTool;
private readonly IVersionWriter versionWriter;

public GitVersionExecutor(ILog log, IConsole console,
IConfigFileLocator configFileLocator, IConfigProvider configProvider,
IConfigurationFileLocator configFileLocator, IConfigurationProvider configurationProvider,
IGitVersionCalculateTool gitVersionCalculateTool, IGitVersionOutputTool gitVersionOutputTool,
IVersionWriter versionWriter, IHelpWriter helpWriter, IGitRepositoryInfo repositoryInfo)
{
this.log = log.NotNull();
this.console = console.NotNull();
this.configFileLocator = configFileLocator.NotNull();
this.configProvider = configProvider.NotNull();
this.configurationProvider = configurationProvider.NotNull();

this.gitVersionCalculateTool = gitVersionCalculateTool.NotNull();
this.gitVersionOutputTool = gitVersionOutputTool.NotNull();
Expand Down Expand Up @@ -65,7 +64,7 @@ private int RunGitVersionTool(GitVersionOptions gitVersionOptions)

var variables = this.gitVersionCalculateTool.CalculateVersionVariables();

var configuration = this.configProvider.Provide(gitVersionOptions.ConfigInfo.OverrideConfig);
var configuration = this.configurationProvider.Provide(gitVersionOptions.ConfigInfo.OverrideConfig);

this.gitVersionOutputTool.OutputVariables(variables, configuration.UpdateBuildNumber ?? true);
this.gitVersionOutputTool.UpdateAssemblyInfo(variables);
Expand Down Expand Up @@ -148,15 +147,15 @@ private bool HandleNonMainCommand(GitVersionOptions gitVersionOptions, out int e

if (gitVersionOptions.Init)
{
this.configProvider.Init(workingDirectory);
this.configurationProvider.Init(workingDirectory);
exitCode = 0;
return true;
}

if (gitVersionOptions.ConfigInfo.ShowConfig)
{
var config = this.configProvider.Provide(workingDirectory);
this.console.WriteLine(config.ToString());
var configuration = this.configurationProvider.Provide(workingDirectory);
this.console.WriteLine(configuration.ToString());
exitCode = 0;
return true;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
using GitVersion.Model.Configuration;
using GitVersion.Configuration;
using YamlDotNet.Serialization;

namespace GitVersion;

internal class OverrideConfigOptionParser
internal class OverrideConfigurationOptionParser
{
private static readonly Lazy<ILookup<string?, PropertyInfo>> _lazySupportedProperties =
new(GetSupportedProperties, true);

private readonly Lazy<Config> lazyConfig = new();
private readonly Lazy<GitVersionConfiguration> lazyConfig = new();

internal static ILookup<string?, PropertyInfo> SupportedProperties => _lazySupportedProperties.Value;

/// <summary>
/// Dynamically creates <see cref="System.Linq.ILookup{TKey, TElement}"/> of
/// <see cref="Config"/> properties supported as a part of command line '/overrideconfig' option.
/// <see cref="GitVersionConfiguration"/> properties supported as a part of command line '/overrideconfig' option.
/// </summary>
/// <returns></returns>
/// <remarks>
/// Lookup keys are created from <see cref="YamlDotNet.Serialization.YamlMemberAttribute"/> to match 'GitVersion.yml'
/// options as close as possible.
/// </remarks>
private static ILookup<string?, PropertyInfo> GetSupportedProperties() => typeof(Config).GetProperties(BindingFlags.Public | BindingFlags.Instance)
private static ILookup<string?, PropertyInfo> GetSupportedProperties() => typeof(GitVersionConfiguration).GetProperties(BindingFlags.Public | BindingFlags.Instance)
.Where(
pi => IsSupportedPropertyType(pi.PropertyType)
&& pi.CanWrite
Expand All @@ -33,7 +33,7 @@ internal class OverrideConfigOptionParser
);

/// <summary>
/// Checks if property <see cref="Type"/> of <see cref="Config"/>
/// Checks if property <see cref="Type"/> of <see cref="GitVersionConfiguration"/>
/// is supported as a part of command line '/overrideconfig' option.
/// </summary>
/// <param name="propertyType">Type we want to check.</param>
Expand Down Expand Up @@ -97,5 +97,5 @@ internal void SetValue(string key, string value)
}
}

internal Config? GetConfig() => this.lazyConfig.IsValueCreated ? this.lazyConfig.Value : null;
internal GitVersionConfiguration? GetConfig() => this.lazyConfig.IsValueCreated ? this.lazyConfig.Value : null;
}
6 changes: 3 additions & 3 deletions src/GitVersion.App/PublicAPI.Shipped.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ GitVersion.Arguments.LogFilePath -> string?
GitVersion.Arguments.NoCache -> bool
GitVersion.Arguments.NoFetch -> bool
GitVersion.Arguments.NoNormalize -> bool
GitVersion.Arguments.Output -> System.Collections.Generic.ISet<GitVersion.Model.OutputType>!
GitVersion.Arguments.Output -> System.Collections.Generic.ISet<GitVersion.OutputType>!
GitVersion.Arguments.OutputFile -> string?
GitVersion.Arguments.OverrideConfig -> GitVersion.Model.Configuration.Config?
GitVersion.Arguments.OverrideConfig -> GitVersion.Configuration.GitVersionConfiguration?
GitVersion.Arguments.ShowConfig -> bool
GitVersion.Arguments.ShowVariable -> string?
GitVersion.Arguments.TargetBranch -> string?
Expand All @@ -37,7 +37,7 @@ GitVersion.GitVersionAppModule.GitVersionAppModule() -> void
GitVersion.GitVersionAppModule.RegisterTypes(Microsoft.Extensions.DependencyInjection.IServiceCollection! services) -> void
GitVersion.GitVersionExecutor
GitVersion.GitVersionExecutor.Execute(GitVersion.GitVersionOptions! gitVersionOptions) -> int
GitVersion.GitVersionExecutor.GitVersionExecutor(GitVersion.Logging.ILog! log, GitVersion.Logging.IConsole! console, GitVersion.Configuration.IConfigFileLocator! configFileLocator, GitVersion.Configuration.IConfigProvider! configProvider, GitVersion.IGitVersionCalculateTool! gitVersionCalculateTool, GitVersion.IGitVersionOutputTool! gitVersionOutputTool, GitVersion.IVersionWriter! versionWriter, GitVersion.IHelpWriter! helpWriter, GitVersion.IGitRepositoryInfo! repositoryInfo) -> void
GitVersion.GitVersionExecutor.GitVersionExecutor(GitVersion.Logging.ILog! log, GitVersion.Logging.IConsole! console, GitVersion.Configuration.IConfigurationFileLocator! configFileLocator, GitVersion.Configuration.IConfigurationProvider! configurationProvider, GitVersion.IGitVersionCalculateTool! gitVersionCalculateTool, GitVersion.IGitVersionOutputTool! gitVersionOutputTool, GitVersion.IVersionWriter! versionWriter, GitVersion.IHelpWriter! helpWriter, GitVersion.IGitRepositoryInfo! repositoryInfo) -> void
GitVersion.GlobbingResolver
GitVersion.GlobbingResolver.GlobbingResolver() -> void
GitVersion.GlobbingResolver.Resolve(string! workingDirectory, string! pattern) -> System.Collections.Generic.IEnumerable<string!>!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,10 +150,10 @@ private void AssertVariablesAreWrittenToFile(string file)
semanticVersion.BuildMetaData.CommitDate = new DateTimeOffset(2022, 4, 6, 16, 10, 59, TimeSpan.FromHours(10));
semanticVersion.BuildMetaData.Sha = "f28807e615e9f06aec8a33c87780374e0c1f6fb8";

var config = new TestEffectiveConfiguration();
var configuration = new TestEffectiveConfiguration();
var variableProvider = this.sp.GetRequiredService<IVariableProvider>();

var variables = variableProvider.GetVariablesFor(semanticVersion, config, false);
var variables = variableProvider.GetVariablesFor(semanticVersion, configuration, false);

this.buildServer.WithPropertyFile(file);

Expand Down
Loading