-
Notifications
You must be signed in to change notification settings - Fork 654
Add assembly-file-versioning-format with support for environment variables #1385
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
asbjornu
merged 9 commits into
GitTools:master
from
ruhullahshah:feature/env_var_support_in_conf_file
Mar 26, 2018
Merged
Changes from 3 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
d93f470
Fix issue Montonically increasing AssemblyFileVersion to satisfy the …
ruhullahshah d0f4994
Fix failing testcases
ruhullahshah 8a16bcb
Adding a unit test for FormatWith method
ruhullahshah b4f6e8a
Added support for assembly-versioning-format, updated testcase for Fo…
ruhullahshah 42ba797
Merge branch 'master' into feature/env_var_support_in_conf_file
ruhullahshah 9f78366
Changed the environment variable indicator from $ to env:, updated th…
ruhullahshah 2642ef1
Updated the regex to include spaces around null propagation operator …
ruhullahshah 588ccad
Added named group for env: in the FormatWith Regex, removed out param…
ruhullahshah 8d6ff9a
Merge branch 'master' into feature/env_var_support_in_conf_file
ruhullahshah File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
75 changes: 75 additions & 0 deletions
75
src/GitVersionCore.Tests/StringFormatWithExtensionTests.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
using System; | ||
|
||
using GitVersion; | ||
using NUnit.Framework; | ||
|
||
namespace GitVersionCore.Tests | ||
{ | ||
[TestFixture] | ||
|
||
public class StringFormatWithExtensionTests | ||
{ | ||
[Test] | ||
public void FormatWith_NoTokens() | ||
{ | ||
var propertyObject = new { }; | ||
var target = "Some String without tokens"; | ||
var expected = target; | ||
var actual = target.FormatWith(propertyObject); | ||
Assert.AreEqual(expected, actual); | ||
} | ||
|
||
[Test] | ||
public void FormatWith_SingleSimpleToken() | ||
{ | ||
var propertyObject = new { SomeProperty = "SomeValue" }; | ||
var target = "{SomeProperty}"; | ||
var expected = "SomeValue"; | ||
var actual = target.FormatWith(propertyObject); | ||
Assert.AreEqual(expected, actual); | ||
} | ||
|
||
[Test] | ||
public void FormatWith_MultipleTokensAndVerbatimText() | ||
{ | ||
var propertyObject = new { SomeProperty = "SomeValue", AnotherProperty = "Other Value" }; | ||
var target = "{SomeProperty} some text {AnotherProperty}"; | ||
var expected = "SomeValue some text Other Value"; | ||
var actual = target.FormatWith(propertyObject); | ||
Assert.AreEqual(expected, actual); | ||
} | ||
|
||
[Test] | ||
public void FormatWith_EnvVarToken() | ||
{ | ||
Environment.SetEnvironmentVariable("GIT_VERSION_TEST_VAR", "Env Var Value"); | ||
var propertyObject = new { }; | ||
var target = "{$GIT_VERSION_TEST_VAR}"; | ||
asbjornu marked this conversation as resolved.
Show resolved
Hide resolved
|
||
var expected = "Env Var Value"; | ||
var actual = target.FormatWith(propertyObject); | ||
Assert.AreEqual(expected, actual); | ||
} | ||
|
||
[Test] | ||
public void FormatWith_EnvVarTokenWithFallback() | ||
{ | ||
Environment.SetEnvironmentVariable("GIT_VERSION_TEST_VAR", "Env Var Value"); | ||
var propertyObject = new { }; | ||
var target = "{$GIT_VERSION_TEST_VAR??fallback}"; | ||
var expected = "Env Var Value"; | ||
var actual = target.FormatWith(propertyObject); | ||
Assert.AreEqual(expected, actual); | ||
} | ||
|
||
[Test] | ||
public void FormatWith_UnsetEnvVarTokenWithFallback() | ||
{ | ||
Environment.SetEnvironmentVariable("GIT_VERSION_UNSET_TEST_VAR", null); | ||
var propertyObject = new { }; | ||
var target = "{$GIT_VERSION_UNSET_TEST_VAR??fallback}"; | ||
var expected = "fallback"; | ||
var actual = target.FormatWith(propertyObject); | ||
Assert.AreEqual(expected, actual); | ||
} | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
using System; | ||
|
||
namespace GitVersion.Helpers | ||
{ | ||
public class EnvironmentHelper | ||
{ | ||
public static string GetEnvironmentVariableForProcess(string envVar) | ||
{ | ||
return Environment.GetEnvironmentVariable(envVar, EnvironmentVariableTarget.Process); | ||
asbjornu marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.