Skip to content

Commit 7c4b172

Browse files
authored
Merge pull request #2146 from gitfool/gh2139
GH2139: GitVersion logging does not include newlines
2 parents 5385735 + 1d16eed commit 7c4b172

File tree

20 files changed

+56
-26
lines changed

20 files changed

+56
-26
lines changed

src/GitVersionCore.Tests/ConfigProviderTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ public void RegexIsRequired()
9696
tag: bugfix";
9797
SetupConfigFileContent(text);
9898
var ex = Should.Throw<GitVersionConfigurationException>(() => configProvider.Provide(repoPath));
99-
ex.Message.ShouldBe("Branch configuration 'bug' is missing required configuration 'regex'\n\n" +
99+
ex.Message.ShouldBe($"Branch configuration 'bug' is missing required configuration 'regex'{System.Environment.NewLine}" +
100100
"See https://gitversion.net/docs/configuration/ for more info");
101101
}
102102

@@ -111,7 +111,7 @@ public void SourceBranchIsRequired()
111111
tag: bugfix";
112112
SetupConfigFileContent(text);
113113
var ex = Should.Throw<GitVersionConfigurationException>(() => configProvider.Provide(repoPath));
114-
ex.Message.ShouldBe("Branch configuration 'bug' is missing required configuration 'source-branches'\n\n" +
114+
ex.Message.ShouldBe($"Branch configuration 'bug' is missing required configuration 'source-branches'{System.Environment.NewLine}" +
115115
"See https://gitversion.net/docs/configuration/ for more info");
116116
}
117117

src/GitVersionCore.Tests/VariableProviderTests.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,9 @@ public void ShouldLogWarningWhenUsingDefaultInformationalVersionInCustomFormat()
4343
Patch = 3,
4444
};
4545

46+
#pragma warning disable CS0618 // Type or member is obsolete
4647
var propertyName = nameof(SemanticVersionFormatValues.DefaultInformationalVersion);
48+
#pragma warning restore CS0618 // Type or member is obsolete
4749
var config = new TestEffectiveConfiguration(assemblyInformationalFormat: $"{{{propertyName}}}");
4850
variableProvider.GetVariablesFor(semVer, config, false);
4951
logMessages.ShouldContain(message => message.Trim().StartsWith("WARN") && message.Contains(propertyName), 1, $"Expected a warning to be logged when using the variable {propertyName} in a configuration format template");

src/GitVersionCore/BuildServers/TeamCity.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,8 @@ public override string GetCurrentBranch(bool usingDynamicRepos)
3434
private void WriteBranchEnvVariableWarning()
3535
{
3636
Log.Warning(@"TeamCity doesn't make the current branch available through environmental variables.
37-
3837
Depending on your authentication and transport setup of your git VCS root things may work. In that case, ignore this warning.
39-
4038
In your TeamCity build configuration, add a parameter called `env.Git_Branch` with value %teamcity.build.vcs.branch.<vcsid>%
41-
4239
See https://gitversion.net/docs/build-server-support/build-server/teamcity for more info");
4340
}
4441

src/GitVersionCore/Configuration/BranchConfigurationCalculator.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ private BranchConfig InheritBranchConfiguration(Branch targetBranch, BranchConfi
145145
}
146146

147147
var branchName = chosenBranch.FriendlyName;
148-
log.Warning(errorMessage + System.Environment.NewLine + System.Environment.NewLine + "Falling back to " + branchName + " branch config");
148+
log.Warning(errorMessage + System.Environment.NewLine + "Falling back to " + branchName + " branch config");
149149

150150
// To prevent infinite loops, make sure that a new branch was chosen.
151151
if (targetBranch.IsSameBranch(chosenBranch))

src/GitVersionCore/Configuration/ConfigExtensions.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,14 +88,14 @@ public static void Reset(this Config config)
8888
var regex = branchConfig.Value.Regex;
8989
if (regex == null)
9090
{
91-
throw new GitVersionConfigurationException($"Branch configuration '{branchConfig.Key}' is missing required configuration 'regex'\n\n" +
91+
throw new GitVersionConfigurationException($"Branch configuration '{branchConfig.Key}' is missing required configuration 'regex'{System.Environment.NewLine}" +
9292
"See https://gitversion.net/docs/configuration/ for more info");
9393
}
9494

9595
var sourceBranches = branchConfig.Value.SourceBranches;
9696
if (sourceBranches == null)
9797
{
98-
throw new GitVersionConfigurationException($"Branch configuration '{branchConfig.Key}' is missing required configuration 'source-branches'\n\n" +
98+
throw new GitVersionConfigurationException($"Branch configuration '{branchConfig.Key}' is missing required configuration 'source-branches'{System.Environment.NewLine}" +
9999
"See https://gitversion.net/docs/configuration/ for more info");
100100
}
101101

@@ -189,7 +189,7 @@ public static BranchConfig GetConfigForBranch(this Config config, string branchN
189189
}
190190
catch (InvalidOperationException)
191191
{
192-
var matchingConfigs = String.Concat(matches.Select(m => $"\n - {m.Key}"));
192+
var matchingConfigs = String.Concat(matches.Select(m => $"{System.Environment.NewLine} - {m.Key}"));
193193
var picked = matches
194194
.Select(kvp => kvp.Value)
195195
.First();

src/GitVersionCore/Configuration/Init/SetConfig/ConfigureBranches.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ protected override string GetPrompt(Config config, string workingDirectory)
4646
return @"Which branch would you like to configure:
4747
4848
0) Go Back
49-
" + string.Join("\r\n", OrderedBranches(config).Select((c, i) => $"{i + 1}) {c.Key}"));
49+
" + string.Join(System.Environment.NewLine, OrderedBranches(config).Select((c, i) => $"{i + 1}) {c.Key}"));
5050
}
5151

5252
private static IOrderedEnumerable<KeyValuePair<string, BranchConfig>> OrderedBranches(Config config)

src/GitVersionCore/Configuration/Init/Wizard/FinishedSetupStep.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ public FinishedSetupStep(IConsole console, IFileSystem fileSystem, ILog log, ICo
1010

1111
protected override string GetPrompt(Config config, string workingDirectory)
1212
{
13-
return "Questions are all done, you can now edit GitVersion's configuration further\r\n" + base.GetPrompt(config, workingDirectory);
13+
return $"Questions are all done, you can now edit GitVersion's configuration further{System.Environment.NewLine}" + base.GetPrompt(config, workingDirectory);
1414
}
1515
}
1616
}

src/GitVersionCore/Configuration/Init/Wizard/GitFlowSetupStep.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ public GitFlowSetupStep(IConsole console, IFileSystem fileSystem, ILog log, ICon
1111

1212
protected override string GetPrompt(Config config, string workingDirectory)
1313
{
14-
return "By default GitVersion will only increment the version of the 'develop' branch every commit, all other branches will increment when tagged\r\n\r\n" +
14+
return $"By default GitVersion will only increment the version of the 'develop' branch every commit, all other branches will increment when tagged{System.Environment.NewLine}{System.Environment.NewLine}" +
1515
base.GetPrompt(config, workingDirectory);
1616
}
1717
}

src/GitVersionCore/Configuration/Init/Wizard/GitHubFlowStep.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ public GitHubFlowStep(IConsole console, IFileSystem fileSystem, ILog log, IConfi
1111

1212
protected override string GetPrompt(Config config, string workingDirectory)
1313
{
14-
return "By default GitVersion will only increment the version when tagged\r\n\r\n" + base.GetPrompt(config, workingDirectory);
14+
return $"By default GitVersion will only increment the version when tagged{System.Environment.NewLine}{System.Environment.NewLine}" + base.GetPrompt(config, workingDirectory);
1515
}
1616
}
1717
}

src/GitVersionCore/GitRepoMetadataProvider.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -218,8 +218,8 @@ public BranchCommit FindCommitBranchWasBranchedFrom(Branch branch, params Branch
218218
if (possibleBranches.Count > 1)
219219
{
220220
var first = possibleBranches.First();
221-
log.Info($"Multiple source branches have been found, picking the first one ({first.Branch.FriendlyName}).\n" +
222-
"This may result in incorrect commit counting.\nOptions were:\n " +
221+
log.Info($"Multiple source branches have been found, picking the first one ({first.Branch.FriendlyName}).{System.Environment.NewLine}" +
222+
$"This may result in incorrect commit counting.{System.Environment.NewLine}Options were:{System.Environment.NewLine}" +
223223
string.Join(", ", possibleBranches.Select(b => b.Branch.FriendlyName)));
224224
return first;
225225
}

0 commit comments

Comments
 (0)