Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/GitVersionCore.Tests/ConfigProviderTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public void RegexIsRequired()
tag: bugfix";
SetupConfigFileContent(text);
var ex = Should.Throw<GitVersionConfigurationException>(() => configProvider.Provide(repoPath));
ex.Message.ShouldBe("Branch configuration 'bug' is missing required configuration 'regex'\n\n" +
ex.Message.ShouldBe($"Branch configuration 'bug' is missing required configuration 'regex'{System.Environment.NewLine}" +
"See https://gitversion.net/docs/configuration/ for more info");
}

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

Expand Down
2 changes: 2 additions & 0 deletions src/GitVersionCore.Tests/VariableProviderTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ public void ShouldLogWarningWhenUsingDefaultInformationalVersionInCustomFormat()
Patch = 3,
};

#pragma warning disable CS0618 // Type or member is obsolete
var propertyName = nameof(SemanticVersionFormatValues.DefaultInformationalVersion);
#pragma warning restore CS0618 // Type or member is obsolete
var config = new TestEffectiveConfiguration(assemblyInformationalFormat: $"{{{propertyName}}}");
variableProvider.GetVariablesFor(semVer, config, false);
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");
Expand Down
3 changes: 0 additions & 3 deletions src/GitVersionCore/BuildServers/TeamCity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,8 @@ public override string GetCurrentBranch(bool usingDynamicRepos)
private void WriteBranchEnvVariableWarning()
{
Log.Warning(@"TeamCity doesn't make the current branch available through environmental variables.

Depending on your authentication and transport setup of your git VCS root things may work. In that case, ignore this warning.

In your TeamCity build configuration, add a parameter called `env.Git_Branch` with value %teamcity.build.vcs.branch.<vcsid>%

See https://gitversion.net/docs/build-server-support/build-server/teamcity for more info");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ private BranchConfig InheritBranchConfiguration(Branch targetBranch, BranchConfi
}

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

// To prevent infinite loops, make sure that a new branch was chosen.
if (targetBranch.IsSameBranch(chosenBranch))
Expand Down
6 changes: 3 additions & 3 deletions src/GitVersionCore/Configuration/ConfigExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,14 +88,14 @@ public static void Reset(this Config config)
var regex = branchConfig.Value.Regex;
if (regex == null)
{
throw new GitVersionConfigurationException($"Branch configuration '{branchConfig.Key}' is missing required configuration 'regex'\n\n" +
throw new GitVersionConfigurationException($"Branch configuration '{branchConfig.Key}' is missing required configuration 'regex'{System.Environment.NewLine}" +
"See https://gitversion.net/docs/configuration/ for more info");
}

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

Expand Down Expand Up @@ -189,7 +189,7 @@ public static BranchConfig GetConfigForBranch(this Config config, string branchN
}
catch (InvalidOperationException)
{
var matchingConfigs = String.Concat(matches.Select(m => $"\n - {m.Key}"));
var matchingConfigs = String.Concat(matches.Select(m => $"{System.Environment.NewLine} - {m.Key}"));
var picked = matches
.Select(kvp => kvp.Value)
.First();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ protected override string GetPrompt(Config config, string workingDirectory)
return @"Which branch would you like to configure:

0) Go Back
" + string.Join("\r\n", OrderedBranches(config).Select((c, i) => $"{i + 1}) {c.Key}"));
" + string.Join(System.Environment.NewLine, OrderedBranches(config).Select((c, i) => $"{i + 1}) {c.Key}"));
}

private static IOrderedEnumerable<KeyValuePair<string, BranchConfig>> OrderedBranches(Config config)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public FinishedSetupStep(IConsole console, IFileSystem fileSystem, ILog log, ICo

protected override string GetPrompt(Config config, string workingDirectory)
{
return "Questions are all done, you can now edit GitVersion's configuration further\r\n" + base.GetPrompt(config, workingDirectory);
return $"Questions are all done, you can now edit GitVersion's configuration further{System.Environment.NewLine}" + base.GetPrompt(config, workingDirectory);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public GitFlowSetupStep(IConsole console, IFileSystem fileSystem, ILog log, ICon

protected override string GetPrompt(Config config, string workingDirectory)
{
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" +
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}" +
base.GetPrompt(config, workingDirectory);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public GitHubFlowStep(IConsole console, IFileSystem fileSystem, ILog log, IConfi

protected override string GetPrompt(Config config, string workingDirectory)
{
return "By default GitVersion will only increment the version when tagged\r\n\r\n" + base.GetPrompt(config, workingDirectory);
return $"By default GitVersion will only increment the version when tagged{System.Environment.NewLine}{System.Environment.NewLine}" + base.GetPrompt(config, workingDirectory);
}
}
}
4 changes: 2 additions & 2 deletions src/GitVersionCore/GitRepoMetadataProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -218,8 +218,8 @@ public BranchCommit FindCommitBranchWasBranchedFrom(Branch branch, params Branch
if (possibleBranches.Count > 1)
{
var first = possibleBranches.First();
log.Info($"Multiple source branches have been found, picking the first one ({first.Branch.FriendlyName}).\n" +
"This may result in incorrect commit counting.\nOptions were:\n " +
log.Info($"Multiple source branches have been found, picking the first one ({first.Branch.FriendlyName}).{System.Environment.NewLine}" +
$"This may result in incorrect commit counting.{System.Environment.NewLine}Options were:{System.Environment.NewLine}" +
string.Join(", ", possibleBranches.Select(b => b.Branch.FriendlyName)));
return first;
}
Expand Down
4 changes: 2 additions & 2 deletions src/GitVersionCore/Helpers/GitRepositoryHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public static void NormalizeGitDirectory(ILog log, IEnvironment environment, str
}

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

// 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.
// If they do, go ahead and checkout that branch
Expand Down Expand Up @@ -203,7 +203,7 @@ private static void CreateFakeBranchPointingAtThePullRequestTip(ILog log, Reposi
GetRemoteTipsUsingUsernamePasswordCredentials(repo, remote, authentication.Username, authentication.Password))
.ToList();

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

var headTipSha = repo.Head.Tip.Sha;

Expand Down
2 changes: 1 addition & 1 deletion src/GitVersionCore/Logging/FileAppender.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public void WriteTo(LogLevel level, string message)

private static void WriteLogEntry(string logFilePath, string str)
{
var contents = $"{DateTime.Now:yyyy-MM-dd HH:mm:ss}\t\t{str}\r\n";
var contents = $"{DateTime.Now:yyyy-MM-dd HH:mm:ss}\t\t{str}{System.Environment.NewLine}";
File.AppendAllText(logFilePath, contents);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/GitVersionCore/Logging/Log.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public void Write(Verbosity verbosity, LogLevel level, string format, params obj
appender.WriteTo(level, formattedString);
}

sb.Append(formattedString);
sb.AppendLine(formattedString);
}

public IDisposable IndentLog(string operationDescription)
Expand Down
2 changes: 2 additions & 0 deletions src/GitVersionCore/OutputVariables/VariableProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,9 @@ private string CheckAndFormatString<T>(string formatString, T source, IEnvironme

private void WarnIfUsingObsoleteFormatValues(string formatString)
{
#pragma warning disable CS0618 // Type or member is obsolete
var obsoletePropertyName = nameof(SemanticVersionFormatValues.DefaultInformationalVersion);
#pragma warning restore CS0618 // Type or member is obsolete
if (formatString.Contains($"{{{obsoletePropertyName}}}"))
{
log.Write(LogLevel.Warn, $"Use format variable '{nameof(SemanticVersionFormatValues.InformationalVersion)}' instead of '{obsoletePropertyName}' which is obsolete and will be removed in a future release.");
Expand Down
16 changes: 16 additions & 0 deletions src/GitVersionExe.Tests/ArgumentParserTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,9 @@ public void HMeansIsHelp()
public void Exec()
{
var arguments = argumentParser.ParseArguments("-exec rake");
#pragma warning disable CS0612 // Type or member is obsolete
arguments.Exec.ShouldBe("rake");
#pragma warning restore CS0612 // Type or member is obsolete
}

[Test]
Expand All @@ -72,15 +74,19 @@ public void ExecWithArgs()
"-execargs",
"clean build"
});
#pragma warning disable CS0612 // Type or member is obsolete
arguments.Exec.ShouldBe("rake");
arguments.ExecArgs.ShouldBe("clean build");
#pragma warning restore CS0612 // Type or member is obsolete
}

[Test]
public void Msbuild()
{
var arguments = argumentParser.ParseArguments("-proj msbuild.proj");
#pragma warning disable CS0612 // Type or member is obsolete
arguments.Proj.ShouldBe("msbuild.proj");
#pragma warning restore CS0612 // Type or member is obsolete
}

[Test]
Expand All @@ -93,16 +99,20 @@ public void MsbuildWithArgs()
"-projargs",
"/p:Configuration=Debug /p:Platform=AnyCPU"
});
#pragma warning disable CS0612 // Type or member is obsolete
arguments.Proj.ShouldBe("msbuild.proj");
arguments.ProjArgs.ShouldBe("/p:Configuration=Debug /p:Platform=AnyCPU");
#pragma warning restore CS0612 // Type or member is obsolete
}

[Test]
public void ExecwithTargetdirectory()
{
var arguments = argumentParser.ParseArguments("targetDirectoryPath -exec rake");
arguments.TargetPath.ShouldBe("targetDirectoryPath");
#pragma warning disable CS0612 // Type or member is obsolete
arguments.Exec.ShouldBe("rake");
#pragma warning restore CS0612 // Type or member is obsolete
}

[Test]
Expand Down Expand Up @@ -374,23 +384,29 @@ public void OtherArgumentsCanBeParsedAfterNofetch()
{
var arguments = argumentParser.ParseArguments("-nofetch -proj foo.sln");
arguments.NoFetch.ShouldBe(true);
#pragma warning disable CS0612 // Type or member is obsolete
arguments.Proj.ShouldBe("foo.sln");
#pragma warning restore CS0612 // Type or member is obsolete
}

[Test]
public void OtherArgumentsCanBeParsedAfterNonormalize()
{
var arguments = argumentParser.ParseArguments("-nonormalize -proj foo.sln");
arguments.NoNormalize.ShouldBe(true);
#pragma warning disable CS0612 // Type or member is obsolete
arguments.Proj.ShouldBe("foo.sln");
#pragma warning restore CS0612 // Type or member is obsolete
}

[Test]
public void OtherArgumentsCanBeParsedAfterNocache()
{
var arguments = argumentParser.ParseArguments("-nocache -proj foo.sln");
arguments.NoCache.ShouldBe(true);
#pragma warning disable CS0612 // Type or member is obsolete
arguments.Proj.ShouldBe("foo.sln");
#pragma warning restore CS0612 // Type or member is obsolete
}

[TestCase("-nofetch -nonormalize -nocache")]
Expand Down
12 changes: 10 additions & 2 deletions src/GitVersionExe/ArgumentParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -149,29 +149,37 @@ public Arguments ParseArguments(string[] commandLineArguments)
if (name.IsSwitch("exec"))
{
EnsureArgumentValueCount(values);
#pragma warning disable CS0612 // Type or member is obsolete
arguments.Exec = value;
#pragma warning restore CS0612 // Type or member is obsolete
continue;
}


if (name.IsSwitch("execargs"))
{
EnsureArgumentValueCount(values);
#pragma warning disable CS0612 // Type or member is obsolete
arguments.ExecArgs = value;
#pragma warning restore CS0612 // Type or member is obsolete
continue;
}

if (name.IsSwitch("proj"))
{
EnsureArgumentValueCount(values);
#pragma warning disable CS0612 // Type or member is obsolete
arguments.Proj = value;
#pragma warning restore CS0612 // Type or member is obsolete
continue;
}

if (name.IsSwitch("projargs"))
{
EnsureArgumentValueCount(values);
#pragma warning disable CS0612 // Type or member is obsolete
arguments.ProjArgs = value;
#pragma warning restore CS0612 // Type or member is obsolete
continue;
}

Expand Down Expand Up @@ -238,8 +246,8 @@ public Arguments ParseArguments(string[] commandLineArguments)

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

Expand Down
4 changes: 4 additions & 0 deletions src/GitVersionExe/ExecCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,16 +83,19 @@ public void Execute()

private static bool RunMsBuildIfNeeded(Arguments args, string workingDirectory, VersionVariables variables, ILog log)
{
#pragma warning disable CS0612 // Type or member is obsolete
if (string.IsNullOrEmpty(args.Proj)) return false;

args.Exec = "dotnet";
args.ExecArgs = $"msbuild \"{args.Proj}\" {args.ProjArgs}";
#pragma warning restore CS0612 // Type or member is obsolete

return RunExecCommandIfNeeded(args, workingDirectory, variables, log);
}

private static bool RunExecCommandIfNeeded(Arguments args, string workingDirectory, VersionVariables variables, ILog log)
{
#pragma warning disable CS0612 // Type or member is obsolete
if (string.IsNullOrEmpty(args.Exec)) return false;

log.Info($"Launching {args.Exec} {args.ExecArgs}");
Expand All @@ -103,6 +106,7 @@ private static bool RunExecCommandIfNeeded(Arguments args, string workingDirecto

if (results != 0)
throw new WarningException($"Execution of {args.Exec} failed, non-zero return code");
#pragma warning restore CS0612 // Type or member is obsolete

return true;
}
Expand Down
7 changes: 4 additions & 3 deletions src/GitVersionExe/GitVersionExecutor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,9 @@ private int VerifyArgumentsAndRun(Arguments arguments)
arguments.Output.Add(OutputType.BuildServer);
}

#pragma warning disable CS0612 // Type or member is obsolete
if (!string.IsNullOrEmpty(arguments.Proj) || !string.IsNullOrEmpty(arguments.Exec))
#pragma warning restore CS0612 // Type or member is obsolete
{
arguments.Output.Add(OutputType.BuildServer);
}
Expand Down Expand Up @@ -118,18 +120,17 @@ private int VerifyArgumentsAndRun(Arguments arguments)
}
catch (WarningException exception)
{
var error = $"An error occurred:\r\n{exception.Message}";
var error = $"An error occurred:{System.Environment.NewLine}{exception.Message}";
log.Warning(error);
return 1;
}
catch (Exception exception)
{
var error = $"An unexpected error occurred:\r\n{exception}";
var error = $"An unexpected error occurred:{System.Environment.NewLine}{exception}";
log.Error(error);

if (arguments == null) return 1;

log.Info(string.Empty);
log.Info("Attempting to show the current git graph (please include in issue): ");
log.Info("Showing max of 100 commits");

Expand Down
2 changes: 1 addition & 1 deletion src/GitVersionTask.MsBuild/GitVersionTask.MsBuild.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

<ItemGroup>
<PackageReference Include="System.Runtime.Loader" Version="4.3.0" />
<PackageReference Include="Microsoft.Build" Version="16.4.0" />
<PackageReference Include="Microsoft.Build" Version="16.4.0" NoWarn="NU1701" />
<PackageReference Include="Microsoft.Build.Tasks.Core" Version="16.4.0" />
</ItemGroup>

Expand Down
2 changes: 1 addition & 1 deletion src/GitVersionTask/MsBuildAppender.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public void WriteTo(LogLevel level, string message)

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