Skip to content

New Variable: EscapedBranchName #2157

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 5, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/input/docs/more-info/variables.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ Running `GitVersion.exe` in your repo will show you what is available. For the
"FullSemVer":"3.0.0-beta.1+1",
"InformationalVersion":"3.0.0-beta.1+1.Branch.release/3.0.0.Sha.28c853159a46b5a87e6cc9c4f6e940c59d6bc68a",
"BranchName":"release/3.0.0",
"EscapedBranchName":"release-3.0.0",
"Sha":"28c853159a46b5a87e6cc9c4f6e940c59d6bc68a",
"ShortSha":"28c8531",
"NuGetVersionV2":"3.0.0-beta0001",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"FullSemVer":"1.2.0-unstable.4+5",
"InformationalVersion":"1.2.0-unstable.4+5.Branch.feature1.Sha.commitSha",
"BranchName":"feature1",
"EscapedBranchName":"feature1",
"Sha":"commitSha",
"ShortSha":"commitShortSha",
"NuGetVersionV2":"1.2.0-unstable0004",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"FullSemVer":"1.2.3+5",
"InformationalVersion":"1.2.3+5.Branch.feature-123.Sha.commitSha",
"BranchName":"feature/123",
"EscapedBranchName":"feature-123",
"Sha":"commitSha",
"ShortSha":"commitShortSha",
"NuGetVersionV2":"1.2.3",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"FullSemVer":"1.2.3+5",
"InformationalVersion":"1.2.3+5.Branch.feature-123.Sha.commitShortSha",
"BranchName":"feature/123",
"EscapedBranchName":"feature-123",
"Sha":"commitSha",
"ShortSha":"commitShortSha",
"NuGetVersionV2":"1.2.3",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"FullSemVer":"1.2.3-unstable.4+5",
"InformationalVersion":"1.2.3-unstable.4+5.Branch.develop.Sha.commitSha",
"BranchName":"develop",
"EscapedBranchName":"develop",
"Sha":"commitSha",
"ShortSha":"commitShortSha",
"NuGetVersionV2":"1.2.3-unstable0004",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"FullSemVer":"1.2.3-unstable.4+5",
"InformationalVersion":"1.2.3-unstable.4+5.Branch.develop.Sha.commitSha",
"BranchName":"develop",
"EscapedBranchName":"develop",
"Sha":"commitSha",
"ShortSha":"commitShortSha",
"NuGetVersionV2":"1.2.3-unstable00004",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"FullSemVer":"1.2.3+5",
"InformationalVersion":"1.2.3+5.Branch.develop.Sha.commitSha",
"BranchName":"develop",
"EscapedBranchName":"develop",
"Sha":"commitSha",
"ShortSha":"commitShortSha",
"NuGetVersionV2":"1.2.3",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"FullSemVer":"1.2.3-unstable.8",
"InformationalVersion":"1.2.3-unstable.8+Branch.develop.Sha.commitSha",
"BranchName":"develop",
"EscapedBranchName":"develop",
"Sha":"commitSha",
"ShortSha":"commitShortSha",
"NuGetVersionV2":"1.2.3-unstable0008",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"FullSemVer":"1.2.3-ci.5",
"InformationalVersion":"1.2.3-ci.5+Branch.develop.Sha.commitSha",
"BranchName":"develop",
"EscapedBranchName":"develop",
"Sha":"commitSha",
"ShortSha":"commitShortSha",
"NuGetVersionV2":"1.2.3-ci0005",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"FullSemVer":"1.2.3+5",
"InformationalVersion":"1.2.3+5.Sha.commitSha",
"BranchName":"",
"EscapedBranchName":"",
"Sha":"commitSha",
"ShortSha":"commitShortSha",
"NuGetVersionV2":"1.2.3",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<Include xmlns="http://schemas.microsoft.com/wix/2006/wi">
<?define AssemblySemFileVer="1.2.3.0"?>
<?define AssemblySemVer="1.2.3.0"?>
Expand All @@ -8,6 +8,7 @@
<?define CommitDate="2019-02-20"?>
<?define CommitsSinceVersionSource="5"?>
<?define CommitsSinceVersionSourcePadded="0005"?>
<?define EscapedBranchName="develop"?>
<?define FullBuildMetaData="5.Branch.develop.Sha.commitSha"?>
<?define FullSemVer="1.2.3+5"?>
<?define InformationalVersion="1.2.3+5.Branch.develop.Sha.commitSha"?>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ static class GitVersionInformation
public static string FullSemVer = "1.2.3-unstable.4+5";
public static string InformationalVersion = "1.2.3-unstable.4+5.Branch.feature1.Sha.commitSha";
public static string BranchName = "feature1";
public static string EscapedBranchName = "feature1";
public static string Sha = "commitSha";
public static string ShortSha = "commitShortSha";
public static string NuGetVersionV2 = "1.2.3-unstable0004";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ module GitVersionInformation
let FullSemVer = "1.2.3-unstable.4+5"
let InformationalVersion = "1.2.3-unstable.4+5.Branch.feature1.Sha.commitSha"
let BranchName = "feature1"
let EscapedBranchName = "feature1"
let Sha = "commitSha"
let ShortSha = "commitShortSha"
let NuGetVersionV2 = "1.2.3-unstable0004"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ NotInheritable Class GitVersionInformation
Public Shared FullSemVer As String = "1.2.3-unstable.4+5"
Public Shared InformationalVersion As String = "1.2.3-unstable.4+5.Branch.feature1.Sha.commitSha"
Public Shared BranchName As String = "feature1"
Public Shared EscapedBranchName As String = "feature1"
Public Shared Sha As String = "commitSha"
Public Shared ShortSha As String = "commitShortSha"
Public Shared NuGetVersionV2 As String = "1.2.3-unstable0004"
Expand Down
4 changes: 4 additions & 0 deletions src/GitVersionCore.Tests/GitVersionExecutorTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ public void CacheFileExistsOnDisk()
FullSemVer: 4.10.3-test.19
InformationalVersion: 4.10.3-test.19+Branch.feature/test.Sha.dd2a29aff0c948e1bdf3dabbe13e1576e70d5f9f
BranchName: feature/test
EscapedBranchName: feature-test
Sha: dd2a29aff0c948e1bdf3dabbe13e1576e70d5f9f
ShortSha: dd2a29af
NuGetVersionV2: 4.10.3-test0019
Expand Down Expand Up @@ -185,6 +186,7 @@ public void CacheFileExistsOnDiskWhenOverrideConfigIsSpecifiedVersionShouldBeDyn
FullSemVer: 4.10.3-test.19
InformationalVersion: 4.10.3-test.19+Branch.feature/test.Sha.dd2a29aff0c948e1bdf3dabbe13e1576e70d5f9f
BranchName: feature/test
EscapedBranchName: feature-test
Sha: dd2a29aff0c948e1bdf3dabbe13e1576e70d5f9f
ShortSha: dd2a29af
NuGetVersionV2: 4.10.3-test0019
Expand Down Expand Up @@ -268,6 +270,7 @@ public void ConfigChangeInvalidatesCache()
FullSemVer: 4.10.3-test.19
InformationalVersion: 4.10.3-test.19+Branch.feature/test.Sha.dd2a29aff0c948e1bdf3dabbe13e1576e70d5f9f
BranchName: feature/test
EscapedBranchName: feature-test
Sha: dd2a29aff0c948e1bdf3dabbe13e1576e70d5f9f
ShortSha: dd2a29af
NuGetVersionV2: 4.10.3-test0019
Expand Down Expand Up @@ -328,6 +331,7 @@ public void NoCacheBypassesCache()
FullSemVer: 4.10.3-test.19
InformationalVersion: 4.10.3-test.19+Branch.feature/test.Sha.dd2a29aff0c948e1bdf3dabbe13e1576e70d5f9f
BranchName: feature/test
EscapedBranchName: feature-test
Sha: dd2a29aff0c948e1bdf3dabbe13e1576e70d5f9f
ShortSha: dd2a29af
NuGetVersionV2: 4.10.3-test0019
Expand Down
6 changes: 3 additions & 3 deletions src/GitVersionCore.Tests/Helpers/TestableVersionVariables.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ internal class TestableVersionVariables : VersionVariables
public TestableVersionVariables(
string major = "", string minor = "", string patch = "", string buildMetaData = "",
string buildMetaDataPadded = "", string fullBuildMetaData = "", string branchName = "",
string sha = "", string shortSha = "", string majorMinorPatch = "", string semVer = "",
string legacySemVer = "", string legacySemVerPadded = "", string fullSemVer = "",
string escapedBranchName = "", string sha = "", string shortSha = "", string majorMinorPatch = "",
string semVer = "", string legacySemVer = "", string legacySemVerPadded = "", string fullSemVer = "",
string assemblySemVer = "", string assemblySemFileVer = "", string preReleaseTag = "",
string preReleaseTagWithDash = "", string preReleaseLabel = "", string preReleaseNumber = "",
string weightedPreReleaseNumber = "", string informationalVersion = "", string commitDate = "",
string nugetVersion = "", string nugetVersionV2 = "", string nugetPreReleaseTag = "",
string nugetPreReleaseTagV2 = "", string versionSourceSha = "", string commitsSinceVersionSource = "",
string commitsSinceVersionSourcePadded = "") : base(
major, minor, patch, buildMetaData, buildMetaDataPadded, fullBuildMetaData, branchName,
major, minor, patch, buildMetaData, buildMetaDataPadded, fullBuildMetaData, branchName, escapedBranchName,
sha, shortSha, majorMinorPatch, semVer, legacySemVer, legacySemVerPadded, fullSemVer,
assemblySemVer, assemblySemFileVer, preReleaseTag, weightedPreReleaseNumber, preReleaseTagWithDash,
preReleaseLabel, preReleaseNumber, informationalVersion, commitDate, nugetVersion, nugetVersionV2,
Expand Down
1 change: 1 addition & 0 deletions src/GitVersionCore/OutputVariables/VariableProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ public VersionVariables GetVariablesFor(SemanticVersion semanticVersion, Effecti
semverFormatValues.BuildMetaDataPadded,
semverFormatValues.FullBuildMetaData,
semverFormatValues.BranchName,
semverFormatValues.EscapedBranchName,
semverFormatValues.Sha,
semverFormatValues.ShortSha,
semverFormatValues.MajorMinorPatch,
Expand Down
3 changes: 3 additions & 0 deletions src/GitVersionCore/OutputVariables/VersionVariables.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public VersionVariables(string major,
string buildMetaDataPadded,
string fullBuildMetaData,
string branchName,
string escapedBranchName,
string sha,
string shortSha,
string majorMinorPatch,
Expand Down Expand Up @@ -49,6 +50,7 @@ public VersionVariables(string major,
BuildMetaDataPadded = buildMetaDataPadded;
FullBuildMetaData = fullBuildMetaData;
BranchName = branchName;
EscapedBranchName = escapedBranchName;
Sha = sha;
ShortSha = shortSha;
MajorMinorPatch = majorMinorPatch;
Expand Down Expand Up @@ -94,6 +96,7 @@ public VersionVariables(string major,
public string FullSemVer { get; private set; }
public string InformationalVersion { get; private set; }
public string BranchName { get; private set; }
public string EscapedBranchName { get; private set; }
public string Sha { get; private set; }
public string ShortSha { get; private set; }
public string NuGetVersionV2 { get; private set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ public SemanticVersionFormatValues(SemanticVersion semver, EffectiveConfiguratio

public string BranchName => semver.BuildMetaData.Branch;

public string EscapedBranchName => semver.BuildMetaData.Branch?.RegexReplace("[^a-zA-Z0-9-]", "-");

public string Sha => semver.BuildMetaData.Sha;

public string ShortSha => semver.BuildMetaData.ShortSha;
Expand Down
3 changes: 3 additions & 0 deletions src/GitVersionTask.MsBuild/Tasks/GetVersion.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ public class GetVersion : GitVersionTaskBase
[Output]
public string BranchName { get; set; }

[Output]
public string EscapedBranchName { get; set; }

[Output]
public string Sha { get; set; }

Expand Down