Skip to content

Commit

Permalink
Adapt to .NET 9 breaking change regarding environment variables
Browse files Browse the repository at this point in the history
  • Loading branch information
AArnott committed Dec 9, 2024
1 parent 0772248 commit 5e15d62
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/NerdBank.GitVersioning/CloudBuildServices/GitLab.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ internal class GitLab : ICloudBuild

/// <inheritdoc/>
public string BuildingTag =>
Environment.GetEnvironmentVariable("CI_COMMIT_TAG") is not null ?
!string.IsNullOrEmpty(Environment.GetEnvironmentVariable("CI_COMMIT_TAG")) ?
$"refs/tags/{Environment.GetEnvironmentVariable("CI_COMMIT_TAG")}" : null;

/// <inheritdoc/>
Expand Down
2 changes: 1 addition & 1 deletion src/NerdBank.GitVersioning/CloudBuildServices/TeamCity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ internal class TeamCity : ICloudBuild
public string GitCommitId => Environment.GetEnvironmentVariable("BUILD_VCS_NUMBER");

/// <inheritdoc/>
public bool IsApplicable => this.GitCommitId is not null;
public bool IsApplicable => !string.IsNullOrEmpty(this.GitCommitId);

/// <inheritdoc/>
public bool IsPullRequest => false;
Expand Down
16 changes: 8 additions & 8 deletions test/Nerdbank.GitVersioning.Tests/BuildIntegrationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -497,18 +497,18 @@ protected static class CloudBuild
public static readonly ImmutableDictionary<string, string> SuppressEnvironment = ImmutableDictionary<string, string>.Empty

// AppVeyor
.Add("APPVEYOR", string.Empty)
.Add("APPVEYOR_REPO_TAG", string.Empty)
.Add("APPVEYOR_REPO_TAG_NAME", string.Empty)
.Add("APPVEYOR_PULL_REQUEST_NUMBER", string.Empty)
.Add("APPVEYOR", null)
.Add("APPVEYOR_REPO_TAG", null)
.Add("APPVEYOR_REPO_TAG_NAME", null)
.Add("APPVEYOR_PULL_REQUEST_NUMBER", null)

// VSTS
.Add("SYSTEM_TEAMPROJECTID", string.Empty)
.Add("BUILD_SOURCEBRANCH", string.Empty)
.Add("SYSTEM_TEAMPROJECTID", null)
.Add("BUILD_SOURCEBRANCH", null)

// Teamcity
.Add("BUILD_VCS_NUMBER", string.Empty)
.Add("BUILD_GIT_BRANCH", string.Empty);
.Add("BUILD_VCS_NUMBER", null)
.Add("BUILD_GIT_BRANCH", null);

public static readonly ImmutableDictionary<string, string> VSTS = SuppressEnvironment
.SetItem("SYSTEM_TEAMPROJECTID", "1");
Expand Down

0 comments on commit 5e15d62

Please sign in to comment.