Handle null commit sha

- Apparently the .version file doesn't always end up in the package
#1498
This commit is contained in:
David Fowler 2016-02-19 20:01:14 -08:00
parent be8cde81b2
commit 39b0880dbe

View file

@ -135,11 +135,11 @@ namespace Microsoft.DotNet.Cli
{
HelpCommand.PrintVersionHeader();
var commitSha = GetCommitSha();
var commitSha = GetCommitSha() ?? "N/A";
Reporter.Output.WriteLine();
Reporter.Output.WriteLine("Product Information:");
Reporter.Output.WriteLine($" Version: {HelpCommand.ProductVersion}");
Reporter.Output.WriteLine($" Commit Sha: {commitSha.Substring(0, 10)}");
Reporter.Output.WriteLine($" Commit Sha: {commitSha}");
Reporter.Output.WriteLine();
var runtimeEnvironment = PlatformServices.Default.Runtime;
Reporter.Output.WriteLine("Runtime Environment:");
@ -166,7 +166,7 @@ namespace Microsoft.DotNet.Cli
if (File.Exists(versionFile))
{
return File.ReadLines(versionFile).FirstOrDefault();
return File.ReadLines(versionFile).FirstOrDefault()?.Substring(0, 10);
}
return null;