Skip to content

Commit 656d194

Browse files
committed
Fix newlines to be platform agnostic
1 parent b08853b commit 656d194

File tree

14 files changed

+20
-23
lines changed

14 files changed

+20
-23
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/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
}

src/GitVersionCore/Helpers/GitRepositoryHelper.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public static void NormalizeGitDirectory(ILog log, IEnvironment environment, str
6262
}
6363

6464
log.Info($"HEAD is detached and points at commit '{headSha}'.");
65-
log.Info(string.Format("Local Refs:\r\n" + string.Join(System.Environment.NewLine, repo.Refs.FromGlob("*").Select(r => $"{r.CanonicalName} ({r.TargetIdentifier})"))));
65+
log.Info($"Local Refs:{System.Environment.NewLine}" + string.Join(System.Environment.NewLine, repo.Refs.FromGlob("*").Select(r => $"{r.CanonicalName} ({r.TargetIdentifier})")));
6666

6767
// In order to decide whether a fake branch is required or not, first check to see if any local branches have the same commit SHA of the head SHA.
6868
// If they do, go ahead and checkout that branch
@@ -203,7 +203,7 @@ private static void CreateFakeBranchPointingAtThePullRequestTip(ILog log, Reposi
203203
GetRemoteTipsUsingUsernamePasswordCredentials(repo, remote, authentication.Username, authentication.Password))
204204
.ToList();
205205

206-
log.Info("Remote Refs:\r\n" + string.Join(System.Environment.NewLine, remoteTips.Select(r => r.CanonicalName)));
206+
log.Info($"Remote Refs:{System.Environment.NewLine}" + string.Join(System.Environment.NewLine, remoteTips.Select(r => r.CanonicalName)));
207207

208208
var headTipSha = repo.Head.Tip.Sha;
209209

src/GitVersionCore/Logging/FileAppender.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public void WriteTo(LogLevel level, string message)
3737

3838
private static void WriteLogEntry(string logFilePath, string str)
3939
{
40-
var contents = $"{DateTime.Now:yyyy-MM-dd HH:mm:ss}\t\t{str}\r\n";
40+
var contents = $"{DateTime.Now:yyyy-MM-dd HH:mm:ss}\t\t{str}{System.Environment.NewLine}";
4141
File.AppendAllText(logFilePath, contents);
4242
}
4343
}

src/GitVersionExe/ArgumentParser.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -238,8 +238,8 @@ public Arguments ParseArguments(string[] commandLineArguments)
238238

239239
if (versionVariable == null)
240240
{
241-
var messageFormat = "{0} requires a valid version variable. Available variables are:\n{1}";
242-
var message = string.Format(messageFormat, name, string.Join(", ", VersionVariables.AvailableVariables.Select(x => string.Concat("'", x, "'"))));
241+
var message = $"{name} requires a valid version variable. Available variables are:{System.Environment.NewLine}" +
242+
string.Join(", ", VersionVariables.AvailableVariables.Select(x => string.Concat("'", x, "'")));
243243
throw new WarningException(message);
244244
}
245245

src/GitVersionExe/GitVersionExecutor.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,13 +118,13 @@ private int VerifyArgumentsAndRun(Arguments arguments)
118118
}
119119
catch (WarningException exception)
120120
{
121-
var error = $"An error occurred:\r\n{exception.Message}";
121+
var error = $"An error occurred:{System.Environment.NewLine}{exception.Message}";
122122
log.Warning(error);
123123
return 1;
124124
}
125125
catch (Exception exception)
126126
{
127-
var error = $"An unexpected error occurred:\r\n{exception}";
127+
var error = $"An unexpected error occurred:{System.Environment.NewLine}{exception}";
128128
log.Error(error);
129129

130130
if (arguments == null) return 1;

src/GitVersionTask/MsBuildAppender.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public void WriteTo(LogLevel level, string message)
2929

3030
private void WriteLogEntry(LogLevel level, string str)
3131
{
32-
var contents = $"{DateTime.Now:yyyy-MM-dd HH:mm:ss}\t\t{str}\r\n";
32+
var contents = $"{DateTime.Now:yyyy-MM-dd HH:mm:ss}\t\t{str}{System.Environment.NewLine}";
3333
switch (level)
3434
{
3535
case LogLevel.None:

0 commit comments

Comments
 (0)