Skip to content

Commit d450d7c

Browse files
authored
Merge branch 'master' into fix/newtonsoft.json-usage
2 parents c5f2df1 + f2183e2 commit d450d7c

File tree

4 files changed

+76
-17
lines changed

4 files changed

+76
-17
lines changed

docs/input/docs/configuration.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,18 @@ When using `mode: ContinuousDeployment`, the value specified in
137137
`continuous-delivery-fallback-tag` will be used as the pre-release tag for
138138
branches which do not have one specified. Default set to `ci`.
139139

140+
Just to clarify: For a build name without `...-ci-<buildnumber>` or in other
141+
words without a `PreReleaseTag` (ergo `"PreReleaseTag":""` in GitVersion's JSON output)
142+
at the end you would need to set `continuous-delivery-fallback-tag` to an empty string (`''`):
143+
144+
```yaml
145+
mode: ContinuousDeployment
146+
continuous-delivery-fallback-tag: ''
147+
...
148+
```
149+
150+
Doing so can be helpful if you use your `master` branch as a `release` branch.
151+
140152
### tag-prefix
141153

142154
A regex which is used to trim git tags before processing (eg v1.0.0). Default is

src/GitVersionCore.Tests/NamedConfigFileLocatorTests.cs

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,37 @@ 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); });
61+
}
62+
63+
[Test]
64+
[Platform(Exclude = "Linux,Unix")]
65+
public void DoNotThrowWhenWorkingAndRepoPathsAreSame_WithDifferentCasing()
66+
{
67+
workingPath = DefaultRepoPath.ToLower();
68+
SetupConfigFileContent(string.Empty, path: workingPath);
69+
70+
Should.NotThrow(() => { configFileLocator.Verify(workingPath, repoPath); });
71+
}
72+
73+
[Test]
74+
public void DoNotThrowWhenConfigFileIsInSubDirectoryOfRepoPath()
75+
{
76+
workingPath = DefaultRepoPath;
77+
78+
options = Options.Create(new Arguments { ConfigFile = "./src/my-config.yaml" });
79+
configFileLocator = new NamedConfigFileLocator(fileSystem, log, options);
80+
SetupConfigFileContent(string.Empty, path: workingPath);
81+
82+
Should.NotThrow(() => { configFileLocator.Verify(workingPath, repoPath); });
83+
}
84+
5485
[Test]
5586
public void NoWarnOnCustomYmlFile()
5687
{

src/GitVersionCore.Tests/TestFileSystem.cs

Lines changed: 29 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,42 +9,49 @@ namespace GitVersionCore.Tests
99
{
1010
public class TestFileSystem : IFileSystem
1111
{
12-
private readonly Dictionary<string, byte[]> fileSystem = new Dictionary<string, byte[]>();
12+
private static IEqualityComparer<string> fileSystemCasingComparer = System.Environment.OSVersion.Platform == PlatformID.Unix ? StringComparer.Ordinal : StringComparer.OrdinalIgnoreCase;
13+
private readonly Dictionary<string, byte[]> fileSystem = new Dictionary<string, byte[]>(fileSystemCasingComparer);
1314

1415
public void Copy(string @from, string to, bool overwrite)
1516
{
16-
if (fileSystem.ContainsKey(to))
17+
var fromPath = Path.GetFullPath(@from);
18+
var toPath = Path.GetFullPath(to);
19+
if (fileSystem.ContainsKey(toPath))
1720
{
1821
if (overwrite)
19-
fileSystem.Remove(to);
22+
fileSystem.Remove(toPath);
2023
else
2124
throw new IOException("File already exists");
2225
}
2326

24-
if (!fileSystem.TryGetValue(from, out var source))
25-
throw new FileNotFoundException($"The source file '{@from}' was not found", from);
27+
if (!fileSystem.TryGetValue(fromPath, out var source))
28+
throw new FileNotFoundException($"The source file '{fromPath}' was not found", from);
2629

27-
fileSystem.Add(to, source);
30+
fileSystem.Add(toPath, source);
2831
}
2932

3033
public void Move(string @from, string to)
3134
{
35+
var fromPath = Path.GetFullPath(@from);
3236
Copy(from, to, false);
33-
fileSystem.Remove(from);
37+
fileSystem.Remove(fromPath);
3438
}
3539

3640
public bool Exists(string file)
3741
{
38-
return fileSystem.ContainsKey(file);
42+
var path = Path.GetFullPath(file);
43+
return fileSystem.ContainsKey(path);
3944
}
4045

4146
public void Delete(string path)
4247
{
43-
fileSystem.Remove(path);
48+
var fullPath = Path.GetFullPath(path);
49+
fileSystem.Remove(fullPath);
4450
}
4551

46-
public string ReadAllText(string path)
52+
public string ReadAllText(string file)
4753
{
54+
var path = Path.GetFullPath(file);
4855
if (!fileSystem.TryGetValue(path, out var content))
4956
throw new FileNotFoundException($"The file '{path}' was not found", path);
5057

@@ -54,15 +61,17 @@ public string ReadAllText(string path)
5461

5562
public void WriteAllText(string file, string fileContents)
5663
{
57-
var encoding = fileSystem.ContainsKey(file)
58-
? EncodingHelper.DetectEncoding(fileSystem[file]) ?? Encoding.UTF8
64+
var path = Path.GetFullPath(file);
65+
var encoding = fileSystem.ContainsKey(path)
66+
? EncodingHelper.DetectEncoding(fileSystem[path]) ?? Encoding.UTF8
5967
: Encoding.UTF8;
60-
WriteAllText(file, fileContents, encoding);
68+
WriteAllText(path, fileContents, encoding);
6169
}
6270

6371
public void WriteAllText(string file, string fileContents, Encoding encoding)
6472
{
65-
fileSystem[file] = encoding.GetBytes(fileContents);
73+
var path = Path.GetFullPath(file);
74+
fileSystem[path] = encoding.GetBytes(fileContents);
6675
}
6776

6877
public IEnumerable<string> DirectoryGetFiles(string directory, string searchPattern, SearchOption searchOption)
@@ -75,8 +84,9 @@ public Stream OpenWrite(string path)
7584
return new TestStream(path, this);
7685
}
7786

78-
public Stream OpenRead(string path)
87+
public Stream OpenRead(string file)
7988
{
89+
var path = Path.GetFullPath(file);
8090
if (fileSystem.ContainsKey(path))
8191
{
8292
var content = fileSystem[path];
@@ -86,8 +96,9 @@ public Stream OpenRead(string path)
8696
throw new FileNotFoundException("File not found.", path);
8797
}
8898

89-
public void CreateDirectory(string path)
99+
public void CreateDirectory(string directory)
90100
{
101+
var path = Path.GetFullPath(directory);
91102
if (fileSystem.ContainsKey(path))
92103
{
93104
fileSystem[path] = new byte[0];
@@ -98,8 +109,9 @@ public void CreateDirectory(string path)
98109
}
99110
}
100111

101-
public bool DirectoryExists(string path)
112+
public bool DirectoryExists(string directory)
102113
{
114+
var path = Path.GetFullPath(directory);
103115
return fileSystem.ContainsKey(path);
104116
}
105117

src/GitVersionCore/Configuration/NamedConfigFileLocator.cs

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

39+
var fileSystemCasingComparer = System.Environment.OSVersion.Platform == PlatformID.Unix ? StringComparison.Ordinal : StringComparison.OrdinalIgnoreCase;
40+
if (Path.GetFullPath(workingConfigFile).Equals(Path.GetFullPath(projectRootConfigFile), fileSystemCasingComparer))
41+
return;
42+
3943
var hasConfigInWorkingDirectory = FileSystem.Exists(workingConfigFile);
4044
var hasConfigInProjectRootDirectory = FileSystem.Exists(projectRootConfigFile);
4145
if (hasConfigInProjectRootDirectory && hasConfigInWorkingDirectory)

0 commit comments

Comments
 (0)