Skip to content

Commit

Permalink
Merge pull request #371 from AArnott/fixPublicReleaseInNBGV
Browse files Browse the repository at this point in the history
Honor PublicRelease environment variable within `nbgv get-version`
  • Loading branch information
AArnott committed Aug 9, 2019
2 parents 2c00141 + 292d30d commit 203a5eb
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/nbgv/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down Expand Up @@ -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;
Expand All @@ -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<VersionOptions.ReleaseVersionIncrement>(versionIncrement, true, out var parsed))
{
Console.Error.WriteLine($"\"{versionIncrement}\" is not a valid version increment");
return ExitCodes.InvalidVersionIncrement;
Expand Down

0 comments on commit 203a5eb

Please sign in to comment.