From 292d30d124fe8b6b5a704e50fd19031d87ea7576 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Fri, 9 Aug 2019 09:27:31 -0600 Subject: [PATCH] Honor PublicRelease environment variable within `nbgv get-version` --- src/nbgv/Program.cs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/nbgv/Program.cs b/src/nbgv/Program.cs index 5781607a..9367d7f4 100644 --- a/src/nbgv/Program.cs +++ b/src/nbgv/Program.cs @@ -285,6 +285,13 @@ private static ExitCodes OnGetVersionCommand(string projectPath, string format, } var oracle = new VersionOracle(searchPath, repository, commit, CloudBuild.Active); + + // Take the PublicRelease environment variable into account, since the build would as well. + if (!string.IsNullOrWhiteSpace(Environment.GetEnvironmentVariable("PublicRelease")) && bool.TryParse(Environment.GetEnvironmentVariable("PublicRelease"), out bool publicRelease)) + { + oracle.PublicRelease = publicRelease; + } + if (string.IsNullOrEmpty(singleVariable)) { switch (format.ToLowerInvariant()) @@ -573,7 +580,7 @@ private static ExitCodes OnPrepareReleaseCommand(string projectPath, string prer } // nextVersion and versionIncrement parameters cannot be combined - if(!string.IsNullOrEmpty(nextVersion) && !string.IsNullOrEmpty(versionIncrement)) + if (!string.IsNullOrEmpty(nextVersion) && !string.IsNullOrEmpty(versionIncrement)) { Console.Error.WriteLine("Options 'nextVersion' and 'versionIncrement' cannot be used at the same time."); return ExitCodes.InvalidParameters; @@ -583,7 +590,7 @@ private static ExitCodes OnPrepareReleaseCommand(string projectPath, string prer VersionOptions.ReleaseVersionIncrement? versionIncrementParsed = default; if (!string.IsNullOrEmpty(versionIncrement)) { - if(!Enum.TryParse< VersionOptions.ReleaseVersionIncrement>(versionIncrement, true, out var parsed)) + if (!Enum.TryParse(versionIncrement, true, out var parsed)) { Console.Error.WriteLine($"\"{versionIncrement}\" is not a valid version increment"); return ExitCodes.InvalidVersionIncrement;