Skip to content

Commit

Permalink
Use a regex to detect a release branch. (#13106)
Browse files Browse the repository at this point in the history
Using the suggested regex from semver.org.
  • Loading branch information
grokys committed Oct 3, 2023
1 parent 008ef53 commit 807ae85
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions nukebuild/BuildParameters.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text.RegularExpressions;
using System.Xml.Linq;
using Nuke.Common;
using Nuke.Common.CI.AzurePipelines;
Expand Down Expand Up @@ -38,7 +39,7 @@ public class BuildParameters
public string RepositoryName { get; }
public string RepositoryBranch { get; }
public string ReleaseConfiguration { get; }
public string ReleaseBranchPrefix { get; }
public Regex ReleaseBranchRegex { get; }
public string MSBuildSolution { get; }
public bool IsLocalBuild { get; }
public bool IsRunningOnUnix { get; }
Expand Down Expand Up @@ -77,7 +78,7 @@ public BuildParameters(Build b)
// CONFIGURATION
MainRepo = "https://github.com/AvaloniaUI/Avalonia";
MasterBranch = "refs/heads/master";
ReleaseBranchPrefix = "refs/heads/release/";
ReleaseBranchRegex = new("^refs/heads/release/(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)(?:-((?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\\.(?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\\+([0-9a-zA-Z-]+(?:\\.[0-9a-zA-Z-]+)*))?$");
ReleaseConfiguration = "Release";
MSBuildSolution = RootDirectory / "dirs.proj";

Expand All @@ -101,8 +102,7 @@ public BuildParameters(Build b)
RepositoryName);
IsMasterBranch = StringComparer.OrdinalIgnoreCase.Equals(MasterBranch,
RepositoryBranch);
IsReleaseBranch = RepositoryBranch?.StartsWith(ReleaseBranchPrefix, StringComparison.OrdinalIgnoreCase) ==
true;
IsReleaseBranch = RepositoryBranch is not null && ReleaseBranchRegex.IsMatch(RepositoryBranch);

IsReleasable = StringComparer.OrdinalIgnoreCase.Equals(ReleaseConfiguration, Configuration);
IsMyGetRelease = IsReleasable;
Expand Down

0 comments on commit 807ae85

Please sign in to comment.