Skip to content

Commit 292d30d

Browse files
committed
Honor PublicRelease environment variable within nbgv get-version
1 parent 2c00141 commit 292d30d

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/nbgv/Program.cs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,13 @@ private static ExitCodes OnGetVersionCommand(string projectPath, string format,
285285
}
286286

287287
var oracle = new VersionOracle(searchPath, repository, commit, CloudBuild.Active);
288+
289+
// Take the PublicRelease environment variable into account, since the build would as well.
290+
if (!string.IsNullOrWhiteSpace(Environment.GetEnvironmentVariable("PublicRelease")) && bool.TryParse(Environment.GetEnvironmentVariable("PublicRelease"), out bool publicRelease))
291+
{
292+
oracle.PublicRelease = publicRelease;
293+
}
294+
288295
if (string.IsNullOrEmpty(singleVariable))
289296
{
290297
switch (format.ToLowerInvariant())
@@ -573,7 +580,7 @@ private static ExitCodes OnPrepareReleaseCommand(string projectPath, string prer
573580
}
574581

575582
// nextVersion and versionIncrement parameters cannot be combined
576-
if(!string.IsNullOrEmpty(nextVersion) && !string.IsNullOrEmpty(versionIncrement))
583+
if (!string.IsNullOrEmpty(nextVersion) && !string.IsNullOrEmpty(versionIncrement))
577584
{
578585
Console.Error.WriteLine("Options 'nextVersion' and 'versionIncrement' cannot be used at the same time.");
579586
return ExitCodes.InvalidParameters;
@@ -583,7 +590,7 @@ private static ExitCodes OnPrepareReleaseCommand(string projectPath, string prer
583590
VersionOptions.ReleaseVersionIncrement? versionIncrementParsed = default;
584591
if (!string.IsNullOrEmpty(versionIncrement))
585592
{
586-
if(!Enum.TryParse< VersionOptions.ReleaseVersionIncrement>(versionIncrement, true, out var parsed))
593+
if (!Enum.TryParse<VersionOptions.ReleaseVersionIncrement>(versionIncrement, true, out var parsed))
587594
{
588595
Console.Error.WriteLine($"\"{versionIncrement}\" is not a valid version increment");
589596
return ExitCodes.InvalidVersionIncrement;

0 commit comments

Comments
 (0)