diff --git a/GitVersion.yml b/.gitversion.yml similarity index 100% rename from GitVersion.yml rename to .gitversion.yml diff --git a/src/GitVersion.Configuration.Tests/Configuration/ConfigurationFileLocatorTests.cs b/src/GitVersion.Configuration.Tests/Configuration/ConfigurationFileLocatorTests.cs index 89393ec5cb..e7b04d800a 100644 --- a/src/GitVersion.Configuration.Tests/Configuration/ConfigurationFileLocatorTests.cs +++ b/src/GitVersion.Configuration.Tests/Configuration/ConfigurationFileLocatorTests.cs @@ -222,7 +222,7 @@ public void NoWarnOnCustomYmlFile() var configurationProvider = (ConfigurationProvider)sp.GetRequiredService(); configurationProvider.ProvideForDirectory(this.repoPath); - stringLogger.Length.ShouldBe(0); + stringLogger.ShouldMatch("No configuration file found, using default configuration"); } [Test] @@ -244,7 +244,7 @@ public void NoWarnOnCustomYmlFileOutsideRepoPath() var configurationProvider = (ConfigurationProvider)sp.GetRequiredService(); configurationProvider.ProvideForDirectory(this.repoPath); - stringLogger.Length.ShouldBe(0); + stringLogger.ShouldMatch("No configuration file found, using default configuration"); } [Test] diff --git a/src/GitVersion.Configuration.Tests/Configuration/ConfigurationProviderTests.cs b/src/GitVersion.Configuration.Tests/Configuration/ConfigurationProviderTests.cs index 206b1573c6..3b350cbe7d 100644 --- a/src/GitVersion.Configuration.Tests/Configuration/ConfigurationProviderTests.cs +++ b/src/GitVersion.Configuration.Tests/Configuration/ConfigurationProviderTests.cs @@ -287,7 +287,7 @@ public void NoWarnOnGitVersionYmlFile() this.configurationProvider.ProvideForDirectory(this.repoPath); var filePath = PathHelper.Combine(this.repoPath, ConfigurationFileLocator.DefaultFileName); - stringLogger.ShouldContain($"Found configuration file at '{filePath}'"); + stringLogger.ShouldContain($"Using configuration file '{filePath}'"); } [Test] diff --git a/src/GitVersion.Configuration/ConfigurationFileLocator.cs b/src/GitVersion.Configuration/ConfigurationFileLocator.cs index 1cdddbb560..de69aef59f 100644 --- a/src/GitVersion.Configuration/ConfigurationFileLocator.cs +++ b/src/GitVersion.Configuration/ConfigurationFileLocator.cs @@ -43,6 +43,7 @@ public void Verify(string? workingDirectory, string? projectRootDirectory) string? customConfigurationFile = GetCustomConfigurationFilePathIfEligable(directoryPath); if (!string.IsNullOrWhiteSpace(customConfigurationFile)) { + this.log.Info($"Found configuration file at '{customConfigurationFile}'"); return customConfigurationFile; } diff --git a/src/GitVersion.Configuration/ConfigurationProvider.cs b/src/GitVersion.Configuration/ConfigurationProvider.cs index 1a506c080a..e201f36b55 100644 --- a/src/GitVersion.Configuration/ConfigurationProvider.cs +++ b/src/GitVersion.Configuration/ConfigurationProvider.cs @@ -1,6 +1,7 @@ using System.IO.Abstractions; using GitVersion.Configuration.Workflows; using GitVersion.Extensions; +using GitVersion.Logging; using Microsoft.Extensions.Options; using YamlDotNet.Core; @@ -9,12 +10,14 @@ namespace GitVersion.Configuration; internal class ConfigurationProvider( IConfigurationFileLocator configFileLocator, IFileSystem fileSystem, + ILog log, IConfigurationSerializer configurationSerializer, IOptions options) : IConfigurationProvider { private readonly IConfigurationFileLocator configFileLocator = configFileLocator.NotNull(); private readonly IFileSystem fileSystem = fileSystem.NotNull(); + private readonly ILog log = log.NotNull(); private readonly IConfigurationSerializer configurationSerializer = configurationSerializer.NotNull(); private readonly IOptions options = options.NotNull(); @@ -72,7 +75,19 @@ private IGitVersionConfiguration ProvideConfiguration(string? configFile, private IReadOnlyDictionary? ReadOverrideConfiguration(string? configFilePath) { - if (configFilePath == null || !fileSystem.File.Exists(configFilePath)) return null; + if (configFilePath == null) + { + this.log.Info("No configuration file found, using default configuration"); + return null; + } + + if (!this.fileSystem.File.Exists(configFilePath)) + { + this.log.Info($"Configuration file '{configFilePath}' not found"); + return null; + } + + this.log.Info($"Using configuration file '{configFilePath}'"); var content = fileSystem.File.ReadAllText(configFilePath); return configurationSerializer.Deserialize>(content); } diff --git a/src/GitVersion.sln b/src/GitVersion.sln index 64df2b6e40..90d4734acb 100644 --- a/src/GitVersion.sln +++ b/src/GitVersion.sln @@ -54,7 +54,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "root", "root", "{7D3A83B4-9 ..\.editorconfig = ..\.editorconfig ..\.gitattributes = ..\.gitattributes ..\.gitignore = ..\.gitignore - ..\GitVersion.yml = ..\GitVersion.yml + ..\.gitversion.yml = ..\.gitversion.yml ..\global.json = ..\global.json ..\GitReleaseManager.yml = ..\GitReleaseManager.yml EndProjectSection