Skip to content

Commit a1017bb

Browse files
committed
When specifying a named configuration, and working directory and repository root are the same, do not throw a warning
1 parent 9e5d482 commit a1017bb

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

src/GitVersionCore.Tests/NamedConfigFileLocatorTests.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,17 @@ public void ThrowsExceptionOnAmbiguousConfigFileLocation()
4343
exception.Message.ShouldBe(expectedMessage);
4444
}
4545

46+
[Test]
47+
public void DoNotThrowWhenWorkingAndRepoPathsAreSame()
48+
{
49+
workingPath = DefaultRepoPath;
50+
51+
SetupConfigFileContent(string.Empty, path: repoPath);
52+
SetupConfigFileContent(string.Empty, path: workingPath);
53+
54+
Should.NotThrow(() => { configFileLocator.Verify(workingPath, repoPath, fileSystem); });
55+
}
56+
4657
[Test]
4758
public void NoWarnOnCustomYmlFile()
4859
{

src/GitVersionCore/Configuration/NamedConfigFileLocator.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,12 @@ private void WarnAboutAmbiguousConfigFileSelection(string workingDirectory, stri
3535
var workingConfigFile = GetConfigFilePath(workingDirectory, fileSystem);
3636
var projectRootConfigFile = GetConfigFilePath(projectRootDirectory, fileSystem);
3737

38+
if (Path.GetFullPath(workingConfigFile).Equals(Path.GetFullPath(projectRootConfigFile)))
39+
return;
40+
3841
var hasConfigInWorkingDirectory = fileSystem.Exists(workingConfigFile);
3942
var hasConfigInProjectRootDirectory = fileSystem.Exists(projectRootConfigFile);
43+
4044
if (hasConfigInProjectRootDirectory && hasConfigInWorkingDirectory)
4145
{
4246
throw new WarningException($"Ambiguous config file selection from '{workingConfigFile}' and '{projectRootConfigFile}'");

0 commit comments

Comments
 (0)