Skip to content

Commit 927d47a

Browse files
committed
Encapsulate all values into single quotes
will be more future proof as it might not break on values that contain whitespaces etc
1 parent 5c4ffde commit 927d47a

File tree

2 files changed

+15
-15
lines changed

2 files changed

+15
-15
lines changed

src/GitVersion.Output.Tests/Output/FormatArgumentTests.cs

+13-13
Original file line numberDiff line numberDiff line change
@@ -68,13 +68,13 @@ public void ShouldOutputFormatWithEnvironmentVariablesTests(string format, strin
6868
output.ShouldBeEquivalentTo(expectedValue);
6969
}
7070

71-
[TestCase("Major", "1")]
72-
[TestCase("MajorMinorPatch", "1.1.0")]
73-
[TestCase("SemVer", "1.1.0-foo.1")]
74-
[TestCase("PreReleaseTagWithDash", "-foo.1")]
75-
[TestCase("AssemblySemFileVer", "1.1.0.0")]
76-
[TestCase("BranchName", "feature/foo")]
77-
[TestCase("FullSemVer", "1.1.0-foo.1+1")]
71+
[TestCase("Major", "'1'")]
72+
[TestCase("MajorMinorPatch", "'1.1.0'")]
73+
[TestCase("SemVer", "'1.1.0-foo.1'")]
74+
[TestCase("PreReleaseTagWithDash", "'-foo.1'")]
75+
[TestCase("AssemblySemFileVer", "'1.1.0.0'")]
76+
[TestCase("BranchName", "'feature/foo'")]
77+
[TestCase("FullSemVer", "'1.1.0-foo.1+1'")]
7878
public void ShouldOutputDotEnvEntries(string variableName, string expectedValue)
7979
{
8080
var fixture = CreateTestRepository();
@@ -127,13 +127,13 @@ public void ShouldOutputAllCalculatedVariablesAsDotEnvEntries()
127127
Assert.That(totalOutputLines, Is.EqualTo(versionVariables.Count()));
128128
}
129129

130-
[TestCase("Major", "0")]
131-
[TestCase("MajorMinorPatch", "0.0.1")]
132-
[TestCase("SemVer", "0.0.1-1")]
130+
[TestCase("Major", "'0'")]
131+
[TestCase("MajorMinorPatch", "'0.0.1'")]
132+
[TestCase("SemVer", "'0.0.1-1'")]
133133
[TestCase("BuildMetaData", "''")]
134-
[TestCase("AssemblySemVer", "0.0.1.0")]
135-
[TestCase("PreReleaseTagWithDash", "-1")]
136-
[TestCase("BranchName", "main")]
134+
[TestCase("AssemblySemVer", "'0.0.1.0'")]
135+
[TestCase("PreReleaseTagWithDash", "'-1'")]
136+
[TestCase("BranchName", "'main'")]
137137
[TestCase("PreReleaseLabel", "''")]
138138
[TestCase("PreReleaseLabelWithDash", "''")]
139139
public void ShouldOutputAllDotEnvEntriesEvenForMinimalRepositories(string variableName, string expectedValue)

src/GitVersion.Output/OutputGenerator/OutputGenerator.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,12 @@ public void Execute(GitVersionVariables variables, OutputContext context)
4040
foreach (var (key, value) in variables.OrderBy(x => x.Key))
4141
{
4242
string prefixedKey = "GitVersion_" + key;
43-
string environmentValue = "''";
43+
string environmentValue = "";
4444
if (!value.IsNullOrEmpty())
4545
{
4646
environmentValue = value;
4747
}
48-
dotEnvEntries.Add(prefixedKey + "=" + environmentValue);
48+
dotEnvEntries.Add($"{prefixedKey}='{environmentValue}'");
4949
}
5050

5151
foreach (var dotEnvEntry in dotEnvEntries)

0 commit comments

Comments
 (0)