Skip to content

Commit c70a12a

Browse files
authored
Merge pull request #333 from haefele/fix332
Add support for BuildingTag in VisualStudioTeamServices
2 parents a4c581a + 7353e8b commit c70a12a

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

src/NerdBank.GitVersioning.Tests/BuildIntegrationTests.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,6 @@ public static IEnumerable<object[]> CloudBuildOfBranch(string branchName)
450450
{
451451
new object[] { CloudBuild.AppVeyor.SetItem("APPVEYOR_REPO_BRANCH", branchName) },
452452
new object[] { CloudBuild.VSTS.SetItem("BUILD_SOURCEBRANCH", $"refs/heads/{branchName}") },
453-
new object[] { CloudBuild.VSTS.SetItem("BUILD_SOURCEBRANCH", branchName) }, // VSTS building a github repo
454453
new object[] { CloudBuild.Teamcity.SetItem("BUILD_GIT_BRANCH", $"refs/heads/{branchName}") },
455454
};
456455
}

src/NerdBank.GitVersioning/CloudBuildServices/VisualStudioTeamServices.cs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,16 @@
1313
/// </remarks>
1414
internal class VisualStudioTeamServices : ICloudBuild
1515
{
16-
public bool IsPullRequest => false; // VSTS doesn't define this.
16+
public bool IsPullRequest => Environment.GetEnvironmentVariable("BUILD_SOURCEBRANCH")?.StartsWith("refs/pull/") ?? false;
1717

18-
public string BuildingTag => null; // VSTS doesn't define this.
19-
20-
public string BuildingBranch => CloudBuild.ShouldStartWith(Environment.GetEnvironmentVariable("BUILD_SOURCEBRANCH"), "refs/heads/");
21-
22-
public string BuildingRef => this.BuildingBranch;
18+
public string BuildingTag => Environment.GetEnvironmentVariable("BUILD_SOURCEBRANCH")?.StartsWith("refs/tags/") ?? false
19+
? Environment.GetEnvironmentVariable("BUILD_SOURCEBRANCH")
20+
: null;
2321

22+
public string BuildingBranch => Environment.GetEnvironmentVariable("BUILD_SOURCEBRANCH")?.StartsWith("refs/heads/") ?? false
23+
? Environment.GetEnvironmentVariable("BUILD_SOURCEBRANCH")
24+
: null;
25+
2426
public string GitCommitId => null;
2527

2628
public bool IsApplicable => !string.IsNullOrEmpty(Environment.GetEnvironmentVariable("SYSTEM_TEAMPROJECTID"));

0 commit comments

Comments
 (0)