Skip to content

Commit 3f959ae

Browse files
pianomanjhJosh Huber
authored andcommitted
When specifying a named configuration, and working directory and repository root are the same, do not throw a warning
1 parent 8b4561f commit 3f959ae

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

src/GitVersionCore.Tests/NamedConfigFileLocatorTests.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,15 @@ public void ThrowsExceptionOnAmbiguousConfigFileLocation()
5151
exception.Message.ShouldBe(expectedMessage);
5252
}
5353

54+
[Test]
55+
public void DoNotThrowWhenWorkingAndRepoPathsAreSame()
56+
{
57+
workingPath = DefaultRepoPath;
58+
SetupConfigFileContent(string.Empty, path: workingPath);
59+
60+
Should.NotThrow(() => { configFileLocator.Verify(workingPath, repoPath, fileSystem); });
61+
}
62+
5463
[Test]
5564
public void NoWarnOnCustomYmlFile()
5665
{

src/GitVersionCore/Configuration/NamedConfigFileLocator.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ private void WarnAboutAmbiguousConfigFileSelection(string workingDirectory, stri
3636
var workingConfigFile = GetConfigFilePath(workingDirectory);
3737
var projectRootConfigFile = GetConfigFilePath(projectRootDirectory);
3838

39+
if (Path.GetFullPath(workingConfigFile).Equals(Path.GetFullPath(projectRootConfigFile)))
40+
return;
41+
3942
var hasConfigInWorkingDirectory = FileSystem.Exists(workingConfigFile);
4043
var hasConfigInProjectRootDirectory = FileSystem.Exists(projectRootConfigFile);
4144
if (hasConfigInProjectRootDirectory && hasConfigInWorkingDirectory)

0 commit comments

Comments
 (0)