diff --git a/.editorconfig b/.editorconfig
new file mode 100644
index 0000000..67fed2a
--- /dev/null
+++ b/.editorconfig
@@ -0,0 +1,75 @@
+root = true
+
+[*]
+end_of_line = crlf
+indent_style = tab
+charset = utf-8
+trim_trailing_whitespace = true
+insert_final_newline = true
+
+[*.cs]
+indent_size = 4
+dotnet_sort_system_directives_first = false
+dotnet_style_coalesce_expression = true : warning
+dotnet_style_collection_initializer = true : warning
+dotnet_style_explicit_tuple_names = true : warning
+dotnet_style_null_propagation = true : warning
+dotnet_style_object_initializer = true : warning
+dotnet_style_parentheses_in_arithmetic_binary_operators = always_for_clarity : warning
+dotnet_style_parentheses_in_other_binary_operators = always_for_clarity : warning
+dotnet_style_parentheses_in_other_operators = always_for_clarity : warning
+dotnet_style_parentheses_in_relational_binary_operators = always_for_clarity : warning
+dotnet_style_predefined_type_for_locals_parameters_members = true : error
+dotnet_style_predefined_type_for_member_access = true : error
+dotnet_style_prefer_auto_properties = true : error
+dotnet_style_prefer_conditional_expression_over_assignment = true
+dotnet_style_prefer_conditional_expression_over_return = true
+dotnet_style_prefer_inferred_anonymous_type_member_names = true : warning
+dotnet_style_prefer_is_null_check_over_reference_equality_method = true : warning
+dotnet_style_qualification_for_event = false : none
+dotnet_style_qualification_for_field = false : none
+dotnet_style_qualification_for_method = false : none
+dotnet_style_qualification_for_property = false : none
+dotnet_style_readonly_field = true : warning
+dotnet_style_require_accessibility_modifiers = always : warning
+csharp_indent_case_contents = true
+csharp_indent_case_contents_when_block = true
+csharp_indent_switch_labels = true
+csharp_new_line_before_catch = true
+csharp_new_line_before_else = true
+csharp_new_line_before_finally = true
+csharp_new_line_before_members_in_anonymous_types = true
+csharp_new_line_before_members_in_object_initializers = true
+csharp_new_line_before_open_brace = all
+csharp_new_line_between_query_expression_clauses = true
+csharp_prefer_braces = true : silent
+csharp_prefer_simple_default_expression = true : warning
+csharp_preserve_single_line_blocks = true
+csharp_preserve_single_line_statements = true
+csharp_space_after_cast = false
+csharp_space_after_colon_in_inheritance_clause = true
+csharp_space_after_keywords_in_control_flow_statements = true
+csharp_space_around_binary_operators = before_and_after
+csharp_space_before_colon_in_inheritance_clause = true
+csharp_space_between_method_call_empty_parameter_list_parentheses = false
+csharp_space_between_method_call_name_and_opening_parenthesis = false
+csharp_space_between_method_call_parameter_list_parentheses = false
+csharp_space_between_method_declaration_empty_parameter_list_parentheses = false
+csharp_space_between_method_declaration_parameter_list_parentheses = false
+csharp_space_between_parentheses = false
+csharp_style_conditional_delegate_call = true : warning
+csharp_style_deconstructed_variable_declaration = true : warning
+csharp_style_expression_bodied_accessors = when_on_single_line : suggestion
+csharp_style_expression_bodied_constructors = false : none
+csharp_style_expression_bodied_indexers = when_on_single_line : suggestion
+csharp_style_expression_bodied_methods = false : none
+csharp_style_expression_bodied_operators = when_on_single_line : suggestion
+csharp_style_expression_bodied_properties = when_on_single_line : suggestion
+csharp_style_inlined_variable_declaration = true : warning
+csharp_style_pattern_local_over_anonymous_function = true : warning
+csharp_style_pattern_matching_over_as_with_null_check = true : warning
+csharp_style_pattern_matching_over_is_with_cast_check = true : warning
+csharp_style_throw_expression = true : warning
+csharp_style_var_elsewhere = true : warning
+csharp_style_var_for_built_in_types = true : warning
+csharp_style_var_when_type_is_apparent = true : warning
diff --git a/.simpleversion.json b/.simpleversion.json
index d3c5e8d..13873b0 100644
--- a/.simpleversion.json
+++ b/.simpleversion.json
@@ -1,22 +1,22 @@
{
- "version": "0.2.0",
- "label": ["alpha1"],
- "branches": {
- "release": [
- "^refs/heads/master$",
- "^refs/heads/preview/.+$",
- "^refs/heads/release/.+$"
- ],
- "overrides": [
- {
- "match": "^refs/heads/feature/.+$",
- "metadata": [ "{shortbranchname}" ]
- },
- {
- "match": "^refs/heads/release/.+$",
- "label": [],
- "metadata": [ "*" ]
- }
- ]
- }
+ "version": "0.2.0",
+ "label": [ "alpha1" ],
+ "branches": {
+ "release": [
+ "^refs/heads/master$",
+ "^refs/heads/preview/.+$",
+ "^refs/heads/release/.+$"
+ ],
+ "overrides": [
+ {
+ "match": "^refs/heads/feature/.+$",
+ "metadata": [ "{shortbranchname}" ]
+ },
+ {
+ "match": "^refs/heads/release/.+$",
+ "label": [],
+ "metadata": [ "*" ]
+ }
+ ]
+ }
}
\ No newline at end of file
diff --git a/Directory.Build.props b/Directory.Build.props
index 294567b..133e514 100644
--- a/Directory.Build.props
+++ b/Directory.Build.props
@@ -1,46 +1,46 @@
-
- 1.0.0
- $(Version)
- $([System.Text.RegularExpressions.Regex]::Match($(Version), '\d+\.\d+\.\d+').Value)
-
+
+ 1.0.0
+ $(Version)
+ $([System.Text.RegularExpressions.Regex]::Match($(Version), '\d+\.\d+\.\d+').Value)
+
-
- net461
-
+
+ net461
+
-
-
- Kieranties
- (c) Kieranties
- SimpleVersion - A simple tool to version your code
- $(MajorMinorPatchVersion).0
- $([System.Text.RegularExpressions.Regex]::Match($(Version), '\d+\.\d+').Value).0.0
- $(Version)$(VersionSuffix)
-
+
+
+ Kieranties
+ (c) Kieranties
+ SimpleVersion - A simple tool to version your code
+ $(MajorMinorPatchVersion).0
+ $([System.Text.RegularExpressions.Regex]::Match($(Version), '\d+\.\d+').Value).0.0
+ $(Version)$(VersionSuffix)
+
-
- Kieran@Kieranties.com
- https://github.com/Kieranties/SimpleVersion
- semver;versioning;git
- https://github.com/Kieranties/SimpleVersion
- git
- https://raw.github.com/Kieranties/SimpleVersion/master/docs/img/logo.png
- MIT
-
+
+ Kieran@Kieranties.com
+ https://github.com/Kieranties/SimpleVersion
+ semver;versioning;git
+ https://github.com/Kieranties/SimpleVersion
+ git
+ https://raw.github.com/Kieranties/SimpleVersion/master/docs/img/logo.png
+ MIT
+
-
- true
- true
-
- $(NoWarn);NU5105
-
+
+ true
+ true
+
+ $(NoWarn);NU5105
+
-
-
-
+
+
+
-
- $(MSBuildThisFileDirectory)shared/SimpleVersion.ruleset
-
+
+ $(MSBuildThisFileDirectory)shared/SimpleVersion.ruleset
+
\ No newline at end of file
diff --git a/Directory.Build.targets b/Directory.Build.targets
index 1e416b0..e71bb65 100644
--- a/Directory.Build.targets
+++ b/Directory.Build.targets
@@ -1,22 +1,22 @@
-
-
- $(GenerateNuspecDependsOn);SetReleaseNotes
-
-
-
-
-
-
-
-
-
-
-
-
-
- @(ReleaseNotes->'%(Identity)', '%0a')
-
-
+
+ $(GenerateNuspecDependsOn);SetReleaseNotes
+
+
+
+
+
+
+
+
+
+
+
+
+
+ @(ReleaseNotes->'%(Identity)', '%0a')
+
+
+
\ No newline at end of file
diff --git a/Packages.props b/Packages.props
index c846132..fa32cdb 100644
--- a/Packages.props
+++ b/Packages.props
@@ -1,33 +1,33 @@
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/SimpleVersion.sln b/SimpleVersion.sln
index ba4e0c3..87eb16a 100644
--- a/SimpleVersion.sln
+++ b/SimpleVersion.sln
@@ -5,6 +5,7 @@ VisualStudioVersion = 16.0.28729.10
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{D5992CB5-3542-41C8-BE85-F52699729C57}"
ProjectSection(SolutionItems) = preProject
+ src\App.props = src\App.props
src\Directory.Build.props = src\Directory.Build.props
EndProjectSection
EndProject
@@ -19,6 +20,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{9EEF54AE-E
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{0F190AA6-731C-425E-894B-F4A63A86200A}"
ProjectSection(SolutionItems) = preProject
+ .editorconfig = .editorconfig
.gitignore = .gitignore
.simpleversion.json = .simpleversion.json
azure-pipelines.yml = azure-pipelines.yml
diff --git a/azure-pipelines.yml b/azure-pipelines.yml
index 7bc5efa..36bf816 100644
--- a/azure-pipelines.yml
+++ b/azure-pipelines.yml
@@ -101,4 +101,4 @@ jobs:
packagesToPush: $(DistDir)/**/*.nupkg
nuGetFeedType: internal
publishVstsFeed: SimpleVersion
- feedsToUse: nuget.config
+ feedsToUse: nuget.config
\ No newline at end of file
diff --git a/global.json b/global.json
index 2a1bab3..746fa4e 100644
--- a/global.json
+++ b/global.json
@@ -1,5 +1,5 @@
{
- "msbuild-sdks": {
- "Microsoft.Build.CentralPackageVersions": "2.0.26"
- }
+ "msbuild-sdks": {
+ "Microsoft.Build.CentralPackageVersions": "2.0.26"
+ }
}
\ No newline at end of file
diff --git a/nuget.config b/nuget.config
index eac1650..6f60b4b 100644
--- a/nuget.config
+++ b/nuget.config
@@ -1,10 +1,10 @@
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/shared/Tests.GlobalSuppressions.cs b/shared/Tests.GlobalSuppressions.cs
index 811f2ed..cb62fe8 100644
--- a/shared/Tests.GlobalSuppressions.cs
+++ b/shared/Tests.GlobalSuppressions.cs
@@ -1,6 +1,6 @@
-// Licensed under the MIT license. See https://kieranties.mit-license.org/ for full license information.
+// Licensed under the MIT license. See https://kieranties.mit-license.org/ for full license information.
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage(
- "Naming",
- "CA1707:Identifiers should not contain underscores",
- Justification = "Use underscores for readability in tests")]
+ "Naming",
+ "CA1707:Identifiers should not contain underscores",
+ Justification = "Use underscores for readability in tests")]
\ No newline at end of file
diff --git a/shared/stylecop.json b/shared/stylecop.json
index 58f69bb..e1e19d1 100644
--- a/shared/stylecop.json
+++ b/shared/stylecop.json
@@ -1,14 +1,14 @@
-{
- "$schema": "https://raw.githubusercontent.com/DotNetAnalyzers/StyleCopAnalyzers/master/StyleCop.Analyzers/StyleCop.Analyzers/Settings/stylecop.schema.json",
- "settings": {
- "documentationRules": {
- "companyName": "Kieranties",
- "copyrightText": "Licensed under the {licenseName} license. See {licenseUri} for full license information.",
- "xmlHeader": false,
- "variables": {
- "licenseName": "MIT",
- "licenseUri": "https://kieranties.mit-license.org/"
- }
- }
- }
-}
+{
+ "$schema": "https://raw.githubusercontent.com/DotNetAnalyzers/StyleCopAnalyzers/master/StyleCop.Analyzers/StyleCop.Analyzers/Settings/stylecop.schema.json",
+ "settings": {
+ "documentationRules": {
+ "companyName": "Kieranties",
+ "copyrightText": "Licensed under the {licenseName} license. See {licenseUri} for full license information.",
+ "xmlHeader": false,
+ "variables": {
+ "licenseName": "MIT",
+ "licenseUri": "https://kieranties.mit-license.org/"
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/App.props b/src/App.props
index 3c353fd..96b26e7 100644
--- a/src/App.props
+++ b/src/App.props
@@ -1,28 +1,28 @@
-
-
-
+
+
+
-
-
-
+
+
+
-
-
- False
- False
+
+
+ False
+ False
-
+
-
- True
-
- None
- False
-
- None
-
+
+ True
+
+ None
+ False
+
+ None
+
-
\ No newline at end of file
+
diff --git a/src/Directory.Build.props b/src/Directory.Build.props
index 19cfeea..02cca55 100644
--- a/src/Directory.Build.props
+++ b/src/Directory.Build.props
@@ -1,9 +1,9 @@
-
-
-
- true
-
-
+
+
+
+
+
+
diff --git a/src/SimpleVersion.Abstractions/Constants.cs b/src/SimpleVersion.Abstractions/Constants.cs
index 260b3ab..5a9245d 100644
--- a/src/SimpleVersion.Abstractions/Constants.cs
+++ b/src/SimpleVersion.Abstractions/Constants.cs
@@ -1,9 +1,9 @@
-// Licensed under the MIT license. See https://kieranties.mit-license.org/ for full license information.
+// Licensed under the MIT license. See https://kieranties.mit-license.org/ for full license information.
namespace SimpleVersion
{
- public static class Constants
- {
- public const string VersionFileName = ".simpleversion.json";
- }
+ public static class Constants
+ {
+ public const string VersionFileName = ".simpleversion.json";
+ }
}
diff --git a/src/SimpleVersion.Abstractions/IEnvironment.cs b/src/SimpleVersion.Abstractions/IEnvironment.cs
index 330d82c..48f5ba4 100644
--- a/src/SimpleVersion.Abstractions/IEnvironment.cs
+++ b/src/SimpleVersion.Abstractions/IEnvironment.cs
@@ -1,4 +1,4 @@
-// Licensed under the MIT license. See https://kieranties.mit-license.org/ for full license information.
+// Licensed under the MIT license. See https://kieranties.mit-license.org/ for full license information.
using System;
using System.Collections.Generic;
@@ -8,8 +8,8 @@
namespace SimpleVersion
{
- public interface IEnvironment
- {
- string GetVariable(string name);
- }
+ public interface IEnvironment
+ {
+ string GetVariable(string name);
+ }
}
diff --git a/src/SimpleVersion.Abstractions/Model/BranchConfiguration.cs b/src/SimpleVersion.Abstractions/Model/BranchConfiguration.cs
index 03ad311..efbb10c 100644
--- a/src/SimpleVersion.Abstractions/Model/BranchConfiguration.cs
+++ b/src/SimpleVersion.Abstractions/Model/BranchConfiguration.cs
@@ -1,17 +1,17 @@
-// Licensed under the MIT license. See https://kieranties.mit-license.org/ for full license information.
+// Licensed under the MIT license. See https://kieranties.mit-license.org/ for full license information.
using System.Collections.Generic;
namespace SimpleVersion.Model
{
- public class BranchConfiguration
- {
- public string Match { get; set; } = string.Empty;
+ public class BranchConfiguration
+ {
+ public string Match { get; set; } = string.Empty;
#pragma warning disable CA2227 // Collection properties should be read only
- public List Label { get; set; } = null;
+ public List Label { get; set; } = null;
- public List MetaData { get; set; } = null;
+ public List MetaData { get; set; } = null;
#pragma warning restore CA2227 // Collection properties should be read only
- }
-}
+ }
+}
\ No newline at end of file
diff --git a/src/SimpleVersion.Abstractions/Model/BranchInfo.cs b/src/SimpleVersion.Abstractions/Model/BranchInfo.cs
index 9612297..98f95e7 100644
--- a/src/SimpleVersion.Abstractions/Model/BranchInfo.cs
+++ b/src/SimpleVersion.Abstractions/Model/BranchInfo.cs
@@ -1,14 +1,14 @@
-// Licensed under the MIT license. See https://kieranties.mit-license.org/ for full license information.
+// Licensed under the MIT license. See https://kieranties.mit-license.org/ for full license information.
using System;
using System.Collections.Generic;
namespace SimpleVersion.Model
{
- public class BranchInfo
- {
- public List Release { get; } = new List();
+ public class BranchInfo
+ {
+ public List Release { get; } = new List();
- public List Overrides { get; } = new List();
- }
-}
+ public List Overrides { get; } = new List();
+ }
+}
\ No newline at end of file
diff --git a/src/SimpleVersion.Abstractions/Model/Configuration.cs b/src/SimpleVersion.Abstractions/Model/Configuration.cs
index fa1f517..06fd039 100644
--- a/src/SimpleVersion.Abstractions/Model/Configuration.cs
+++ b/src/SimpleVersion.Abstractions/Model/Configuration.cs
@@ -1,21 +1,21 @@
-// Licensed under the MIT license. See https://kieranties.mit-license.org/ for full license information.
+// Licensed under the MIT license. See https://kieranties.mit-license.org/ for full license information.
using System.Collections.Generic;
namespace SimpleVersion.Model
{
#pragma warning disable CA1724
- public class Configuration
+ public class Configuration
#pragma warning restore CA1724
- {
- public string Version { get; set; } = string.Empty;
+ {
+ public string Version { get; set; } = string.Empty;
- public int OffSet { get; set; } = 0;
+ public int OffSet { get; set; } = 0;
- public List Label { get; } = new List();
+ public List Label { get; } = new List();
- public List MetaData { get; } = new List();
+ public List MetaData { get; } = new List();
- public BranchInfo Branches { get; set; } = new BranchInfo();
- }
-}
+ public BranchInfo Branches { get; set; } = new BranchInfo();
+ }
+}
\ No newline at end of file
diff --git a/src/SimpleVersion.Abstractions/Model/LabelConfiguration.cs b/src/SimpleVersion.Abstractions/Model/LabelConfiguration.cs
index 5e9af49..eef90d1 100644
--- a/src/SimpleVersion.Abstractions/Model/LabelConfiguration.cs
+++ b/src/SimpleVersion.Abstractions/Model/LabelConfiguration.cs
@@ -1,4 +1,4 @@
-// Licensed under the MIT license. See https://kieranties.mit-license.org/ for full license information.
+// Licensed under the MIT license. See https://kieranties.mit-license.org/ for full license information.
using System;
using System.Collections.Generic;
@@ -8,8 +8,8 @@
namespace SimpleVersion.Model
{
- public class LabelConfiguration
- {
- public List Label { get; } = new List();
- }
-}
+ public class LabelConfiguration
+ {
+ public List Label { get; } = new List();
+ }
+}
\ No newline at end of file
diff --git a/src/SimpleVersion.Abstractions/Model/VersionResult.cs b/src/SimpleVersion.Abstractions/Model/VersionResult.cs
index 253261c..362500a 100644
--- a/src/SimpleVersion.Abstractions/Model/VersionResult.cs
+++ b/src/SimpleVersion.Abstractions/Model/VersionResult.cs
@@ -1,31 +1,31 @@
-// Licensed under the MIT license. See https://kieranties.mit-license.org/ for full license information.
+// Licensed under the MIT license. See https://kieranties.mit-license.org/ for full license information.
using System.Collections.Generic;
namespace SimpleVersion.Model
{
- public class VersionResult
- {
- public string Version { get; set; } = string.Empty;
+ public class VersionResult
+ {
+ public string Version { get; set; } = string.Empty;
- public int Major { get; set; } = 0;
+ public int Major { get; set; } = 0;
- public int Minor { get; set; } = 0;
+ public int Minor { get; set; } = 0;
- public int Patch { get; set; } = 0;
+ public int Patch { get; set; } = 0;
- public int Revision { get; set; } = 0;
+ public int Revision { get; set; } = 0;
- public int Height { get; set; } = 0;
+ public int Height { get; set; } = 0;
- public string HeightPadded => Height.ToString("D4", System.Globalization.CultureInfo.CurrentCulture);
+ public string HeightPadded => Height.ToString("D4", System.Globalization.CultureInfo.CurrentCulture);
- public string Sha { get; set; } = string.Empty;
+ public string Sha { get; set; } = string.Empty;
- public string BranchName { get; set; } = string.Empty;
+ public string BranchName { get; set; } = string.Empty;
- public string CanonicalBranchName { get; set; } = string.Empty;
+ public string CanonicalBranchName { get; set; } = string.Empty;
- public IDictionary Formats { get; } = new Dictionary(System.StringComparer.OrdinalIgnoreCase);
- }
-}
+ public IDictionary Formats { get; } = new Dictionary(System.StringComparer.OrdinalIgnoreCase);
+ }
+}
\ No newline at end of file
diff --git a/src/SimpleVersion.Abstractions/Pipeline/ICalculatorProcess.cs b/src/SimpleVersion.Abstractions/Pipeline/ICalculatorProcess.cs
index 07064a1..4156447 100644
--- a/src/SimpleVersion.Abstractions/Pipeline/ICalculatorProcess.cs
+++ b/src/SimpleVersion.Abstractions/Pipeline/ICalculatorProcess.cs
@@ -1,9 +1,9 @@
-// Licensed under the MIT license. See https://kieranties.mit-license.org/ for full license information.
+// Licensed under the MIT license. See https://kieranties.mit-license.org/ for full license information.
namespace SimpleVersion.Pipeline
{
- public interface ICalculatorProcess
- {
- void Apply(VersionContext context);
- }
-}
+ public interface ICalculatorProcess
+ {
+ void Apply(VersionContext context);
+ }
+}
\ No newline at end of file
diff --git a/src/SimpleVersion.Abstractions/Pipeline/IVersionCalculator.cs b/src/SimpleVersion.Abstractions/Pipeline/IVersionCalculator.cs
index c159dad..3a93d1b 100644
--- a/src/SimpleVersion.Abstractions/Pipeline/IVersionCalculator.cs
+++ b/src/SimpleVersion.Abstractions/Pipeline/IVersionCalculator.cs
@@ -1,13 +1,13 @@
-// Licensed under the MIT license. See https://kieranties.mit-license.org/ for full license information.
+// Licensed under the MIT license. See https://kieranties.mit-license.org/ for full license information.
using SimpleVersion.Model;
namespace SimpleVersion.Pipeline
{
- public interface IVersionCalculator
- {
- IVersionCalculator AddProcessor() where T : ICalculatorProcess, new();
+ public interface IVersionCalculator
+ {
+ IVersionCalculator AddProcessor() where T : ICalculatorProcess, new();
- VersionResult GetResult(string path);
- }
-}
+ VersionResult GetResult(string path);
+ }
+}
\ No newline at end of file
diff --git a/src/SimpleVersion.Abstractions/Pipeline/VersionContext.cs b/src/SimpleVersion.Abstractions/Pipeline/VersionContext.cs
index 45673b4..b05f764 100644
--- a/src/SimpleVersion.Abstractions/Pipeline/VersionContext.cs
+++ b/src/SimpleVersion.Abstractions/Pipeline/VersionContext.cs
@@ -1,17 +1,17 @@
-// Licensed under the MIT license. See https://kieranties.mit-license.org/ for full license information.
+// Licensed under the MIT license. See https://kieranties.mit-license.org/ for full license information.
using SimpleVersion.Model;
namespace SimpleVersion.Pipeline
{
- public class VersionContext
- {
- public string Path { get; set; } = string.Empty;
+ public class VersionContext
+ {
+ public string Path { get; set; } = string.Empty;
- public string RepositoryPath { get; set; } = string.Empty;
+ public string RepositoryPath { get; set; } = string.Empty;
- public Configuration Configuration { get; set; } = new Configuration();
+ public Configuration Configuration { get; set; } = new Configuration();
- public VersionResult Result { get; set; } = new VersionResult();
- }
+ public VersionResult Result { get; set; } = new VersionResult();
+ }
}
\ No newline at end of file
diff --git a/src/SimpleVersion.Abstractions/Rules/IRule.cs b/src/SimpleVersion.Abstractions/Rules/IRule.cs
index 044ee4a..41f1b85 100644
--- a/src/SimpleVersion.Abstractions/Rules/IRule.cs
+++ b/src/SimpleVersion.Abstractions/Rules/IRule.cs
@@ -1,16 +1,16 @@
-// Licensed under the MIT license. See https://kieranties.mit-license.org/ for full license information.
+// Licensed under the MIT license. See https://kieranties.mit-license.org/ for full license information.
using SimpleVersion.Pipeline;
using System.Collections.Generic;
namespace SimpleVersion.Rules
{
- public interface IRule
- {
- string Token { get; }
+ public interface IRule
+ {
+ string Token { get; }
- T Resolve(VersionContext context, T value);
+ T Resolve(VersionContext context, T value);
- IEnumerable Apply(VersionContext context, IEnumerable value);
- }
-}
+ IEnumerable Apply(VersionContext context, IEnumerable value);
+ }
+}
\ No newline at end of file
diff --git a/src/SimpleVersion.Abstractions/SimpleVersion.Abstractions.csproj b/src/SimpleVersion.Abstractions/SimpleVersion.Abstractions.csproj
index f196693..c6c51a4 100644
--- a/src/SimpleVersion.Abstractions/SimpleVersion.Abstractions.csproj
+++ b/src/SimpleVersion.Abstractions/SimpleVersion.Abstractions.csproj
@@ -1,8 +1,8 @@
-
-
+
+
-
- SimpleVersion
-
+
+ SimpleVersion
+
-
+
\ No newline at end of file
diff --git a/src/SimpleVersion.Cake/CakeAliases.cs b/src/SimpleVersion.Cake/CakeAliases.cs
index eb73855..45bb345 100644
--- a/src/SimpleVersion.Cake/CakeAliases.cs
+++ b/src/SimpleVersion.Cake/CakeAliases.cs
@@ -1,4 +1,4 @@
-// Licensed under the MIT license. See https://kieranties.mit-license.org/ for full license information.
+// Licensed under the MIT license. See https://kieranties.mit-license.org/ for full license information.
using Cake.Core;
using Cake.Core.Annotations;
@@ -7,19 +7,19 @@
namespace Cake.SimpleVersion
{
- public static class CakeAliases
- {
- [CakeMethodAlias]
- public static VersionResult SimpleVersion(
- this ICakeContext context,
- string path = null)
- {
- if (string.IsNullOrWhiteSpace(path))
- path = context.Environment.WorkingDirectory.FullPath;
+ public static class CakeAliases
+ {
+ [CakeMethodAlias]
+ public static VersionResult SimpleVersion(
+ this ICakeContext context,
+ string path = null)
+ {
+ if (string.IsNullOrWhiteSpace(path))
+ path = context.Environment.WorkingDirectory.FullPath;
- return VersionCalculator
- .Default()
- .GetResult(path);
- }
- }
+ return VersionCalculator
+ .Default()
+ .GetResult(path);
+ }
+ }
}
diff --git a/src/SimpleVersion.Cake/SimpleVersion.Cake.csproj b/src/SimpleVersion.Cake/SimpleVersion.Cake.csproj
index 4c0a9be..41abf8e 100644
--- a/src/SimpleVersion.Cake/SimpleVersion.Cake.csproj
+++ b/src/SimpleVersion.Cake/SimpleVersion.Cake.csproj
@@ -1,29 +1,29 @@
-
-
+
+
-
+
-
- Cake.SimpleVersion
- $(PackageTags);Cake
-
+
+ Cake.SimpleVersion
+ $(PackageTags);Cake
+
-
- $(TargetsForTfmSpecificContentInPackage);PackBuildOutputs
-
+
+ $(TargetsForTfmSpecificContentInPackage);PackBuildOutputs
+
-
-
-
+
+
+
-
-
-
+
+
- lib\$(TargetFramework)\
-
-
-
+ lib\$(TargetFramework)\
+
+
+
diff --git a/src/SimpleVersion.Command/Program.cs b/src/SimpleVersion.Command/Program.cs
index 1863308..4f99ec2 100644
--- a/src/SimpleVersion.Command/Program.cs
+++ b/src/SimpleVersion.Command/Program.cs
@@ -1,4 +1,4 @@
-// Licensed under the MIT license. See https://kieranties.mit-license.org/ for full license information.
+// Licensed under the MIT license. See https://kieranties.mit-license.org/ for full license information.
using Newtonsoft.Json;
using SimpleVersion.Pipeline;
@@ -6,30 +6,32 @@
namespace SimpleVersion.Command
{
- public sealed class Program
- {
- public static int Main(string[] args)
- {
- var exitCode = 0;
- try {
- var path = System.IO.Directory.GetCurrentDirectory();
- if (args.Length > 0)
- path = args[0];
+ public sealed class Program
+ {
+ public static int Main(string[] args)
+ {
+ var exitCode = 0;
+ try
+ {
+ var path = System.IO.Directory.GetCurrentDirectory();
+ if (args.Length > 0)
+ path = args[0];
- var result = VersionCalculator
- .Default()
- .GetResult(path);
+ var result = VersionCalculator
+ .Default()
+ .GetResult(path);
- Console.Out.WriteLine(JsonConvert.SerializeObject(result, Formatting.Indented));
- }
+ Console.Out.WriteLine(JsonConvert.SerializeObject(result, Formatting.Indented));
+ }
#pragma warning disable CA1031 // Do not catch general exception types
- catch (Exception ex) {
- Console.Error.WriteLine($"[Error] {ex.Message}");
- exitCode = -1;
- }
+ catch (Exception ex)
+ {
+ Console.Error.WriteLine($"[Error] {ex.Message}");
+ exitCode = -1;
+ }
#pragma warning restore CA1031 // Do not catch general exception types
- return exitCode;
- }
- }
+ return exitCode;
+ }
+ }
}
diff --git a/src/SimpleVersion.Command/SimpleVersion.Command.csproj b/src/SimpleVersion.Command/SimpleVersion.Command.csproj
index 8b22ca7..4c85506 100644
--- a/src/SimpleVersion.Command/SimpleVersion.Command.csproj
+++ b/src/SimpleVersion.Command/SimpleVersion.Command.csproj
@@ -1,24 +1,24 @@
-
-
+
+
-
+
-
- Exe
- SimpleVersion
-
+
+ Exe
+ SimpleVersion
+
-
- $(TargetsForTfmSpecificContentInPackage);PackBuildOutputs
- SimpleVersion.Command
-
+
+ $(TargetsForTfmSpecificContentInPackage);PackBuildOutputs
+ SimpleVersion.Command
+
-
-
-
+
+
- tools\
-
-
-
+ tools\
+
+
+
diff --git a/src/SimpleVersion.Core/Comparers/ConfigurationVersionLabelComparer.cs b/src/SimpleVersion.Core/Comparers/ConfigurationVersionLabelComparer.cs
index 2ee9371..f304d2a 100644
--- a/src/SimpleVersion.Core/Comparers/ConfigurationVersionLabelComparer.cs
+++ b/src/SimpleVersion.Core/Comparers/ConfigurationVersionLabelComparer.cs
@@ -1,4 +1,4 @@
-// Licensed under the MIT license. See https://kieranties.mit-license.org/ for full license information.
+// Licensed under the MIT license. See https://kieranties.mit-license.org/ for full license information.
using SimpleVersion.Model;
using System;
@@ -7,48 +7,45 @@
namespace SimpleVersion.Comparers
{
- public class ConfigurationVersionLabelComparer : IEqualityComparer
- {
- public bool Equals(Configuration x, Configuration y)
- {
- if (ReferenceEquals(x, y))
- return true;
-
- if (x == null && y != null)
- return false;
-
- if (y == null && x != null)
- return false;
-
- if(x.Version == y.Version)
- {
- if (x.Label != null)
- {
- return y.Label == null ? false : x.Label.SequenceEqual(y.Label);
- }
- else
- {
- return y.Label == null;
- }
- }
-
- return false;
- }
-
- public int GetHashCode(Configuration configuration)
- {
- if(configuration is null)
- throw new ArgumentNullException(nameof(configuration));
-
- if (configuration.Version is null)
+ public class ConfigurationVersionLabelComparer : IEqualityComparer
+ {
+ public bool Equals(Configuration x, Configuration y)
+ {
+ if (ReferenceEquals(x, y)) return true;
+
+ if (x == null && y != null) return false;
+
+ if (y == null && x != null) return false;
+
+ if (x.Version == y.Version)
+ {
+ if (x.Label != null)
+ {
+ return y.Label == null ? false : x.Label.SequenceEqual(y.Label);
+ }
+ else
+ {
+ return y.Label == null;
+ }
+ }
+
+ return false;
+ }
+
+ public int GetHashCode(Configuration configuration)
+ {
+ if (configuration is null)
+ throw new ArgumentNullException(nameof(configuration));
+
+ if (configuration.Version is null)
#pragma warning disable CA2208 // Instantiate argument exceptions correctly
- throw new ArgumentNullException("Version");
+ throw new ArgumentNullException("Version");
- if (configuration.Label is null)
- throw new ArgumentNullException("Label");
+ if (configuration.Label is null)
+ throw new ArgumentNullException("Label");
#pragma warning restore CA2208 // Instantiate argument exceptions correctly
- return configuration.Version.GetHashCode() * 17 + configuration.Label.GetHashCode();
- }
- }
+ return (configuration.Version.GetHashCode() * 17) + configuration.Label.GetHashCode();
+ }
+ }
}
diff --git a/src/SimpleVersion.Core/Pipeline/BuildServers/AzureDevopsProcess.cs b/src/SimpleVersion.Core/Pipeline/BuildServers/AzureDevopsProcess.cs
index fbe44d1..ae4aa44 100644
--- a/src/SimpleVersion.Core/Pipeline/BuildServers/AzureDevopsProcess.cs
+++ b/src/SimpleVersion.Core/Pipeline/BuildServers/AzureDevopsProcess.cs
@@ -1,32 +1,32 @@
-// Licensed under the MIT license. See https://kieranties.mit-license.org/ for full license information.
+// Licensed under the MIT license. See https://kieranties.mit-license.org/ for full license information.
using System;
using System.Text.RegularExpressions;
namespace SimpleVersion.Pipeline.BuildServers
{
- public class AzureDevopsProcess : ICalculatorProcess
- {
- private static Regex _trim = new Regex(@"^refs\/(heads\/)?", RegexOptions.IgnoreCase);
- private readonly IEnvironment _env;
+ public class AzureDevopsProcess : ICalculatorProcess
+ {
+ private static readonly Regex _trim = new Regex(@"^refs\/(heads\/)?", RegexOptions.IgnoreCase);
+ private readonly IEnvironment _env;
- public AzureDevopsProcess(): this(new VersioningEnvironment())
- {
+ public AzureDevopsProcess() : this(new VersioningEnvironment())
+ {
- }
+ }
- public AzureDevopsProcess(IEnvironment env)
- {
- _env = env;
- }
+ public AzureDevopsProcess(IEnvironment env)
+ {
+ _env = env;
+ }
- public void Apply(VersionContext context)
- {
- if (_env.GetVariable("TF_BUILD").ToBool())
- {
- context.Result.CanonicalBranchName = _env.GetVariable("BUILD_SOURCEBRANCH");
- context.Result.BranchName = _trim.Replace(context.Result.CanonicalBranchName, string.Empty); ;
- }
- }
- }
+ public void Apply(VersionContext context)
+ {
+ if (_env.GetVariable("TF_BUILD").ToBool())
+ {
+ context.Result.CanonicalBranchName = _env.GetVariable("BUILD_SOURCEBRANCH");
+ context.Result.BranchName = _trim.Replace(context.Result.CanonicalBranchName, string.Empty); ;
+ }
+ }
+ }
}
diff --git a/src/SimpleVersion.Core/Pipeline/Formatting/Semver1FormatProcess.cs b/src/SimpleVersion.Core/Pipeline/Formatting/Semver1FormatProcess.cs
index a23910b..add4375 100644
--- a/src/SimpleVersion.Core/Pipeline/Formatting/Semver1FormatProcess.cs
+++ b/src/SimpleVersion.Core/Pipeline/Formatting/Semver1FormatProcess.cs
@@ -1,31 +1,31 @@
-// Licensed under the MIT license. See https://kieranties.mit-license.org/ for full license information.
+// Licensed under the MIT license. See https://kieranties.mit-license.org/ for full license information.
using SimpleVersion.Rules;
namespace SimpleVersion.Pipeline.Formatting
{
- public class Semver1FormatProcess : ICalculatorProcess
- {
- public void Apply(VersionContext context)
- {
- var rules = new IRule[]
- {
- new HeightRule(true),
- ShortShaRule.Instance,
- BranchNameRule.Instance,
- ShortBranchNameRule.Instance,
- BranchNameSuffixRule.Instance
- };
+ public class Semver1FormatProcess : ICalculatorProcess
+ {
+ public void Apply(VersionContext context)
+ {
+ var rules = new IRule[]
+ {
+ new HeightRule(true),
+ ShortShaRule.Instance,
+ BranchNameRule.Instance,
+ ShortBranchNameRule.Instance,
+ BranchNameSuffixRule.Instance
+ };
- var labelParts = context.Configuration.Label.ApplyRules(context, rules);
- var label = string.Join("-", labelParts).ResolveRules(context, rules);
+ var labelParts = context.Configuration.Label.ApplyRules(context, rules);
+ var label = string.Join("-", labelParts).ResolveRules(context, rules);
- var format = context.Result.Version;
+ var format = context.Result.Version;
- if (!string.IsNullOrWhiteSpace(label))
- format += $"-{label}";
+ if (!string.IsNullOrWhiteSpace(label))
+ format += $"-{label}";
- context.Result.Formats["Semver1"] = format;
- }
- }
+ context.Result.Formats["Semver1"] = format;
+ }
+ }
}
diff --git a/src/SimpleVersion.Core/Pipeline/Formatting/Semver2FormatProcess.cs b/src/SimpleVersion.Core/Pipeline/Formatting/Semver2FormatProcess.cs
index c5dbfd6..dc896e4 100644
--- a/src/SimpleVersion.Core/Pipeline/Formatting/Semver2FormatProcess.cs
+++ b/src/SimpleVersion.Core/Pipeline/Formatting/Semver2FormatProcess.cs
@@ -1,35 +1,35 @@
-// Licensed under the MIT license. See https://kieranties.mit-license.org/ for full license information.
+// Licensed under the MIT license. See https://kieranties.mit-license.org/ for full license information.
using SimpleVersion.Rules;
namespace SimpleVersion.Pipeline.Formatting
{
- public class Semver2FormatProcess : ICalculatorProcess
- {
- public void Apply(VersionContext context)
- {
- var rules = new IRule[]
- {
- HeightRule.Instance,
- ShortShaRule.Instance,
- BranchNameRule.Instance,
- ShortBranchNameRule.Instance,
- BranchNameSuffixRule.Instance
- };
+ public class Semver2FormatProcess : ICalculatorProcess
+ {
+ public void Apply(VersionContext context)
+ {
+ var rules = new IRule[]
+ {
+ HeightRule.Instance,
+ ShortShaRule.Instance,
+ BranchNameRule.Instance,
+ ShortBranchNameRule.Instance,
+ BranchNameSuffixRule.Instance
+ };
- var labelParts = context.Configuration.Label.ApplyRules(context, rules);
- var label = string.Join(".", labelParts).ResolveRules(context, rules);
- var meta = string.Join(".", context.Configuration.MetaData).ResolveRules(context, rules);
-
- var format = context.Result.Version;
+ var labelParts = context.Configuration.Label.ApplyRules(context, rules);
+ var label = string.Join(".", labelParts).ResolveRules(context, rules);
+ var meta = string.Join(".", context.Configuration.MetaData).ResolveRules(context, rules);
- if (!string.IsNullOrWhiteSpace(label))
- format += $"-{label}";
+ var format = context.Result.Version;
- if (!string.IsNullOrWhiteSpace(meta))
- format += $"+{meta}";
+ if (!string.IsNullOrWhiteSpace(label))
+ format += $"-{label}";
- context.Result.Formats["Semver2"] = format;
- }
- }
+ if (!string.IsNullOrWhiteSpace(meta))
+ format += $"+{meta}";
+
+ context.Result.Formats["Semver2"] = format;
+ }
+ }
}
diff --git a/src/SimpleVersion.Core/Pipeline/Formatting/VersionFormatProcess.cs b/src/SimpleVersion.Core/Pipeline/Formatting/VersionFormatProcess.cs
index e893dbf..114fcde 100644
--- a/src/SimpleVersion.Core/Pipeline/Formatting/VersionFormatProcess.cs
+++ b/src/SimpleVersion.Core/Pipeline/Formatting/VersionFormatProcess.cs
@@ -1,33 +1,33 @@
-// Licensed under the MIT license. See https://kieranties.mit-license.org/ for full license information.
+// Licensed under the MIT license. See https://kieranties.mit-license.org/ for full license information.
using SimpleVersion.Rules;
using System;
namespace SimpleVersion.Pipeline.Formatting
{
- public class VersionFormatProcess : ICalculatorProcess
- {
- public void Apply(VersionContext context)
- {
- var versionString = HeightRule.Instance.Resolve(context, context.Configuration.Version);
+ public class VersionFormatProcess : ICalculatorProcess
+ {
+ public void Apply(VersionContext context)
+ {
+ var versionString = HeightRule.Instance.Resolve(context, context.Configuration.Version);
- if (Version.TryParse(versionString, out var version))
- {
- context.Result.Major = version.Major > -1 ? version.Major : 0;
- context.Result.Minor = version.Minor > -1 ? version.Minor : 0;
- context.Result.Patch = version.Build > -1 ? version.Build : 0;
+ if (Version.TryParse(versionString, out var version))
+ {
+ context.Result.Major = version.Major > -1 ? version.Major : 0;
+ context.Result.Minor = version.Minor > -1 ? version.Minor : 0;
+ context.Result.Patch = version.Build > -1 ? version.Build : 0;
- context.Result.Version = $"{context.Result.Major}.{context.Result.Minor}.{context.Result.Patch}";
- if(version.Revision > -1)
- {
- context.Result.Version += $".{version.Revision}";
- context.Result.Revision = version.Revision;
- }
- }
- else
- {
- throw new InvalidOperationException($"Version '{versionString}' is not in a valid format");
- }
- }
- }
+ context.Result.Version = $"{context.Result.Major}.{context.Result.Minor}.{context.Result.Patch}";
+ if (version.Revision > -1)
+ {
+ context.Result.Version += $".{version.Revision}";
+ context.Result.Revision = version.Revision;
+ }
+ }
+ else
+ {
+ throw new InvalidOperationException($"Version '{versionString}' is not in a valid format");
+ }
+ }
+ }
}
diff --git a/src/SimpleVersion.Core/Pipeline/ResolveConfigurationProcess.cs b/src/SimpleVersion.Core/Pipeline/ResolveConfigurationProcess.cs
index cf3d0a1..fa71d5d 100644
--- a/src/SimpleVersion.Core/Pipeline/ResolveConfigurationProcess.cs
+++ b/src/SimpleVersion.Core/Pipeline/ResolveConfigurationProcess.cs
@@ -1,4 +1,4 @@
-// Licensed under the MIT license. See https://kieranties.mit-license.org/ for full license information.
+// Licensed under the MIT license. See https://kieranties.mit-license.org/ for full license information.
using LibGit2Sharp;
using SVM = SimpleVersion.Model;
@@ -11,136 +11,137 @@
namespace SimpleVersion.Pipeline
{
- public class ResolveConfigurationProcess : ICalculatorProcess
- {
- private static readonly ConfigurationVersionLabelComparer _comparer = new ConfigurationVersionLabelComparer();
-
- public void Apply(VersionContext context)
- {
- if (context == null)
- throw new ArgumentNullException(nameof(context));
-
- if (string.IsNullOrWhiteSpace(context.RepositoryPath))
- throw new ArgumentException($"{nameof(context.RepositoryPath)} must be a directory");
-
- using(var repo = new Repository(context.RepositoryPath)){
- if(string.IsNullOrWhiteSpace(context.Result.CanonicalBranchName))
- context.Result.CanonicalBranchName = repo.Head.CanonicalName;
-
- if(string.IsNullOrWhiteSpace(context.Result.BranchName))
- context.Result.BranchName = repo.Head.FriendlyName;
-
- var config = GetConfiguration(repo.Head?.Tip, context)
- ?? throw new InvalidOperationException($"Could not read '{Constants.VersionFileName}', has it been committed?");
-
- context.Configuration = config;
-
- PopulateResult(context, repo);
- }
- }
-
- private void PopulateResult(VersionContext context, Repository repo)
- {
- // Get the state of this tree to compare for diffs
- var tipTree = repo.Head.Tip.Tree;
-
- // Initialise count - The current commit counts, include offset
- var height = 1 + context.Configuration.OffSet;
-
- // skip the first commit as that is our baseline
- var commits = GetReachableCommits(repo).Skip(1).GetEnumerator();
-
- while (commits.MoveNext())
- {
- // Get the current tree
- var next = commits.Current.Tree;
- // Perform a diff
- var diff = repo.Diff.Compare(next, tipTree);
- // If a change to the file is found, stop counting
- if (HasVersionChange(diff, commits.Current, context))
- break;
-
- // Increment height
- height++;
- }
-
- context.Result.Sha = repo.Head.Tip.Sha;
- context.Result.Height = height;
- }
-
- private static bool HasVersionChange(
- TreeChanges diff,
- Commit commit,
- VersionContext context)
- {
- if (diff.Any(d => d.Path == Constants.VersionFileName))
- {
- var commitConfig = GetConfiguration(commit, context);
- return commitConfig != null && !_comparer.Equals(context.Configuration, commitConfig);
- }
-
- return false;
- }
-
- private static IEnumerable GetReachableCommits(Repository repo)
- {
- var filter = new CommitFilter
- {
- FirstParentOnly = true,
- IncludeReachableFrom = repo.Head,
- SortBy = CommitSortStrategies.Reverse
- };
-
- return repo.Commits.QueryBy(filter).Reverse();
- }
-
- private static SVM.Configuration GetConfiguration(Commit commit, VersionContext context)
- {
- var gitObj = commit?.Tree[Constants.VersionFileName]?.Target;
- if (gitObj == null)
- return null;
-
- var config = Read((gitObj as Blob).GetContentText());
- ApplyConfigOverrides(config, context);
- return config;
- }
-
- private static void ApplyConfigOverrides(SVM.Configuration config, VersionContext context)
- {
- if (config == null)
- return;
-
- var firstMatch = config.Branches
- .Overrides.FirstOrDefault(x => Regex.IsMatch(context.Result.CanonicalBranchName, x.Match, RegexOptions.IgnoreCase));
-
- if (firstMatch != null)
- {
- if (firstMatch.Label != null)
- {
- config.Label.Clear();
- config.Label.AddRange(firstMatch.Label);
- }
-
- if(firstMatch.MetaData != null)
- {
- config.MetaData.Clear();
- config.MetaData.AddRange(firstMatch.MetaData);
- }
- }
- }
- private static SVM.Configuration Read(string rawConfiguration)
- {
- try
- {
- return JsonConvert.DeserializeObject(rawConfiguration);
- }
+ public class ResolveConfigurationProcess : ICalculatorProcess
+ {
+ private static readonly ConfigurationVersionLabelComparer _comparer = new ConfigurationVersionLabelComparer();
+
+ public void Apply(VersionContext context)
+ {
+ if (context == null)
+ throw new ArgumentNullException(nameof(context));
+
+ if (string.IsNullOrWhiteSpace(context.RepositoryPath))
+ throw new ArgumentException($"{nameof(context.RepositoryPath)} must be a directory");
+
+ using (var repo = new Repository(context.RepositoryPath))
+ {
+ if (string.IsNullOrWhiteSpace(context.Result.CanonicalBranchName))
+ context.Result.CanonicalBranchName = repo.Head.CanonicalName;
+
+ if (string.IsNullOrWhiteSpace(context.Result.BranchName))
+ context.Result.BranchName = repo.Head.FriendlyName;
+
+ var config = GetConfiguration(repo.Head?.Tip, context)
+ ?? throw new InvalidOperationException($"Could not read '{Constants.VersionFileName}', has it been committed?");
+
+ context.Configuration = config;
+
+ PopulateResult(context, repo);
+ }
+ }
+
+ private void PopulateResult(VersionContext context, Repository repo)
+ {
+ // Get the state of this tree to compare for diffs
+ var tipTree = repo.Head.Tip.Tree;
+
+ // Initialise count - The current commit counts, include offset
+ var height = 1 + context.Configuration.OffSet;
+
+ // skip the first commit as that is our baseline
+ var commits = GetReachableCommits(repo).Skip(1).GetEnumerator();
+
+ while (commits.MoveNext())
+ {
+ // Get the current tree
+ var next = commits.Current.Tree;
+ // Perform a diff
+ var diff = repo.Diff.Compare(next, tipTree);
+ // If a change to the file is found, stop counting
+ if (HasVersionChange(diff, commits.Current, context))
+ break;
+
+ // Increment height
+ height++;
+ }
+
+ context.Result.Sha = repo.Head.Tip.Sha;
+ context.Result.Height = height;
+ }
+
+ private static bool HasVersionChange(
+ TreeChanges diff,
+ Commit commit,
+ VersionContext context)
+ {
+ if (diff.Any(d => d.Path == Constants.VersionFileName))
+ {
+ var commitConfig = GetConfiguration(commit, context);
+ return commitConfig != null && !_comparer.Equals(context.Configuration, commitConfig);
+ }
+
+ return false;
+ }
+
+ private static IEnumerable GetReachableCommits(Repository repo)
+ {
+ var filter = new CommitFilter
+ {
+ FirstParentOnly = true,
+ IncludeReachableFrom = repo.Head,
+ SortBy = CommitSortStrategies.Reverse
+ };
+
+ return repo.Commits.QueryBy(filter).Reverse();
+ }
+
+ private static SVM.Configuration GetConfiguration(Commit commit, VersionContext context)
+ {
+ var gitObj = commit?.Tree[Constants.VersionFileName]?.Target;
+ if (gitObj == null)
+ return null;
+
+ var config = Read((gitObj as Blob).GetContentText());
+ ApplyConfigOverrides(config, context);
+ return config;
+ }
+
+ private static void ApplyConfigOverrides(SVM.Configuration config, VersionContext context)
+ {
+ if (config == null)
+ return;
+
+ var firstMatch = config.Branches
+ .Overrides.FirstOrDefault(x => Regex.IsMatch(context.Result.CanonicalBranchName, x.Match, RegexOptions.IgnoreCase));
+
+ if (firstMatch != null)
+ {
+ if (firstMatch.Label != null)
+ {
+ config.Label.Clear();
+ config.Label.AddRange(firstMatch.Label);
+ }
+
+ if (firstMatch.MetaData != null)
+ {
+ config.MetaData.Clear();
+ config.MetaData.AddRange(firstMatch.MetaData);
+ }
+ }
+ }
+ private static SVM.Configuration Read(string rawConfiguration)
+ {
+ try
+ {
+ return JsonConvert.DeserializeObject(rawConfiguration);
+ }
#pragma warning disable CA1031 // Do not catch general exception types
- catch
- {
- //TODO handle logger of invalid parsing
- return null;
- }
+ catch
+ {
+ //TODO handle logger of invalid parsing
+ return null;
+ }
#pragma warning restore CA1031 // Do not catch general exception types
- }
- }
+ }
+ }
}
diff --git a/src/SimpleVersion.Core/Pipeline/ResolveRepositoryPathProcess.cs b/src/SimpleVersion.Core/Pipeline/ResolveRepositoryPathProcess.cs
index ec46a38..46be045 100644
--- a/src/SimpleVersion.Core/Pipeline/ResolveRepositoryPathProcess.cs
+++ b/src/SimpleVersion.Core/Pipeline/ResolveRepositoryPathProcess.cs
@@ -1,4 +1,4 @@
-// Licensed under the MIT license. See https://kieranties.mit-license.org/ for full license information.
+// Licensed under the MIT license. See https://kieranties.mit-license.org/ for full license information.
using LibGit2Sharp;
using System;
@@ -6,24 +6,24 @@
namespace SimpleVersion.Pipeline
{
- public class ResolveRepositoryPathProcess : ICalculatorProcess
- {
- public void Apply(VersionContext context)
- {
- if (context == null)
- throw new ArgumentNullException(nameof(context));
+ public class ResolveRepositoryPathProcess : ICalculatorProcess
+ {
+ public void Apply(VersionContext context)
+ {
+ if (context == null)
+ throw new ArgumentNullException(nameof(context));
- if (string.IsNullOrWhiteSpace(context.Path))
- throw new Exception("Context path should be populated");
+ if (string.IsNullOrWhiteSpace(context.Path))
+ throw new Exception("Context path should be populated");
- var resolvedPath = Repository.Discover(context.Path);
+ var resolvedPath = Repository.Discover(context.Path);
- if (string.IsNullOrWhiteSpace(resolvedPath))
- throw new DirectoryNotFoundException($"Could not find git repository at '{context.Path}' or any parent directory");
+ if (string.IsNullOrWhiteSpace(resolvedPath))
+ throw new DirectoryNotFoundException($"Could not find git repository at '{context.Path}' or any parent directory");
- // resolvedPath is full pth to .git folder. We want the repo root.
- resolvedPath = resolvedPath.Trim(Path.DirectorySeparatorChar);
- context.RepositoryPath = Directory.GetParent(resolvedPath).FullName;
- }
- }
+ // resolvedPath is full pth to .git folder. We want the repo root.
+ resolvedPath = resolvedPath.Trim(Path.DirectorySeparatorChar);
+ context.RepositoryPath = Directory.GetParent(resolvedPath).FullName;
+ }
+ }
}
diff --git a/src/SimpleVersion.Core/Pipeline/VersionCalculator.cs b/src/SimpleVersion.Core/Pipeline/VersionCalculator.cs
index 43ed299..869a346 100644
--- a/src/SimpleVersion.Core/Pipeline/VersionCalculator.cs
+++ b/src/SimpleVersion.Core/Pipeline/VersionCalculator.cs
@@ -1,4 +1,4 @@
-// Licensed under the MIT license. See https://kieranties.mit-license.org/ for full license information.
+// Licensed under the MIT license. See https://kieranties.mit-license.org/ for full license information.
using SimpleVersion.Model;
using SimpleVersion.Pipeline.BuildServers;
@@ -8,33 +8,33 @@
namespace SimpleVersion.Pipeline
{
- public class VersionCalculator : IVersionCalculator
- {
- public static IVersionCalculator Default()
- => new VersionCalculator()
- .AddProcessor()
- .AddProcessor()
- .AddProcessor()
- .AddProcessor()
- .AddProcessor()
- .AddProcessor();
+ public class VersionCalculator : IVersionCalculator
+ {
+ public static IVersionCalculator Default()
+ => new VersionCalculator()
+ .AddProcessor()
+ .AddProcessor()
+ .AddProcessor()
+ .AddProcessor()
+ .AddProcessor()
+ .AddProcessor();
- private readonly Queue> _queue = new Queue>();
+ private readonly Queue> _queue = new Queue>();
- public IVersionCalculator AddProcessor() where T : ICalculatorProcess, new()
- {
- _queue.Enqueue(new Lazy(() => new T()));
- return this;
- }
+ public IVersionCalculator AddProcessor() where T : ICalculatorProcess, new()
+ {
+ _queue.Enqueue(new Lazy(() => new T()));
+ return this;
+ }
- public VersionResult GetResult(string path)
- {
- var ctx = new VersionContext { Path = path };
+ public VersionResult GetResult(string path)
+ {
+ var ctx = new VersionContext { Path = path };
- foreach (var processor in _queue)
- processor.Value.Apply(ctx);
+ foreach (var processor in _queue)
+ processor.Value.Apply(ctx);
- return ctx.Result;
- }
- }
+ return ctx.Result;
+ }
+ }
}
diff --git a/src/SimpleVersion.Core/Rules/BaseBranchNameRule.cs b/src/SimpleVersion.Core/Rules/BaseBranchNameRule.cs
index 1157d8e..635e43c 100644
--- a/src/SimpleVersion.Core/Rules/BaseBranchNameRule.cs
+++ b/src/SimpleVersion.Core/Rules/BaseBranchNameRule.cs
@@ -1,4 +1,4 @@
-// Licensed under the MIT license. See https://kieranties.mit-license.org/ for full license information.
+// Licensed under the MIT license. See https://kieranties.mit-license.org/ for full license information.
using System;
using System.Collections.Generic;
@@ -10,41 +10,41 @@
namespace SimpleVersion.Rules
{
- public abstract class BaseBranchNameRule : IRule
- {
- private const string _defaultPattern = "[^a-z0-9]";
-
- protected BaseBranchNameRule() : this(_defaultPattern)
- {
- }
-
- protected BaseBranchNameRule(string pattern)
- {
- Pattern = new Regex(pattern, RegexOptions.IgnoreCase);
- }
-
- public abstract string Token { get; protected set; }
-
- public Regex Pattern { get; protected set; }
-
- public virtual IEnumerable Apply(VersionContext context, IEnumerable value)
- {
- // No default implementation applies branch name
- return value;
- }
-
- public virtual string Resolve(VersionContext context, string value)
- {
- if (Regex.IsMatch(value, Token, RegexOptions.IgnoreCase))
- {
- var name = ResolveBranchName(context);
- name = Pattern.Replace(name, "");
- return Regex.Replace(value, Regex.Escape(Token), name, RegexOptions.IgnoreCase);
- }
-
- return value;
- }
-
- protected abstract string ResolveBranchName(VersionContext context);
- }
+ public abstract class BaseBranchNameRule : IRule
+ {
+ private const string _defaultPattern = "[^a-z0-9]";
+
+ protected BaseBranchNameRule() : this(_defaultPattern)
+ {
+ }
+
+ protected BaseBranchNameRule(string pattern)
+ {
+ Pattern = new Regex(pattern, RegexOptions.IgnoreCase);
+ }
+
+ public abstract string Token { get; protected set; }
+
+ public Regex Pattern { get; protected set; }
+
+ public virtual IEnumerable Apply(VersionContext context, IEnumerable value)
+ {
+ // No default implementation applies branch name
+ return value;
+ }
+
+ public virtual string Resolve(VersionContext context, string value)
+ {
+ if (Regex.IsMatch(value, Token, RegexOptions.IgnoreCase))
+ {
+ var name = ResolveBranchName(context);
+ name = Pattern.Replace(name, "");
+ return Regex.Replace(value, Regex.Escape(Token), name, RegexOptions.IgnoreCase);
+ }
+
+ return value;
+ }
+
+ protected abstract string ResolveBranchName(VersionContext context);
+ }
}
diff --git a/src/SimpleVersion.Core/Rules/BranchNameRule.cs b/src/SimpleVersion.Core/Rules/BranchNameRule.cs
index fb6536d..f2150bd 100644
--- a/src/SimpleVersion.Core/Rules/BranchNameRule.cs
+++ b/src/SimpleVersion.Core/Rules/BranchNameRule.cs
@@ -1,26 +1,26 @@
-// Licensed under the MIT license. See https://kieranties.mit-license.org/ for full license information.
+// Licensed under the MIT license. See https://kieranties.mit-license.org/ for full license information.
using System;
using SimpleVersion.Pipeline;
namespace SimpleVersion.Rules
{
- public class BranchNameRule : BaseBranchNameRule
- {
- private static Lazy _default = new Lazy(() => new BranchNameRule());
+ public class BranchNameRule : BaseBranchNameRule
+ {
+ private static readonly Lazy _default = new Lazy(() => new BranchNameRule());
- public static BranchNameRule Instance => _default.Value;
+ public static BranchNameRule Instance => _default.Value;
- public BranchNameRule() : base()
- {
- }
+ public BranchNameRule() : base()
+ {
+ }
- public BranchNameRule(string pattern) : base(pattern)
- {
- }
+ public BranchNameRule(string pattern) : base(pattern)
+ {
+ }
- public override string Token { get; protected set; } = "{branchname}";
+ public override string Token { get; protected set; } = "{branchname}";
- protected override string ResolveBranchName(VersionContext context) => context.Result.CanonicalBranchName;
- }
+ protected override string ResolveBranchName(VersionContext context) => context.Result.CanonicalBranchName;
+ }
}
diff --git a/src/SimpleVersion.Core/Rules/BranchNameSuffixRule.cs b/src/SimpleVersion.Core/Rules/BranchNameSuffixRule.cs
index 6d593e7..d2ccf5a 100644
--- a/src/SimpleVersion.Core/Rules/BranchNameSuffixRule.cs
+++ b/src/SimpleVersion.Core/Rules/BranchNameSuffixRule.cs
@@ -1,29 +1,29 @@
-// Licensed under the MIT license. See https://kieranties.mit-license.org/ for full license information.
+// Licensed under the MIT license. See https://kieranties.mit-license.org/ for full license information.
using SimpleVersion.Pipeline;
using System;
namespace SimpleVersion.Rules
{
- public class BranchNameSuffixRule : BaseBranchNameRule
- {
- private static Lazy _default = new Lazy(() => new BranchNameSuffixRule());
+ public class BranchNameSuffixRule : BaseBranchNameRule
+ {
+ private static readonly Lazy _default = new Lazy(() => new BranchNameSuffixRule());
- public static BranchNameSuffixRule Instance => _default.Value;
+ public static BranchNameSuffixRule Instance => _default.Value;
- public BranchNameSuffixRule() : base()
- {
- }
+ public BranchNameSuffixRule() : base()
+ {
+ }
- public BranchNameSuffixRule(string pattern) : base(pattern)
- {
- }
-
- public override string Token { get; protected set; } = "{branchnamesuffix}";
+ public BranchNameSuffixRule(string pattern) : base(pattern)
+ {
+ }
- protected override string ResolveBranchName(VersionContext context)
- {
- return context.Result.CanonicalBranchName.Substring(context.Result.CanonicalBranchName.LastIndexOf('/') + 1);
- }
- }
+ public override string Token { get; protected set; } = "{branchnamesuffix}";
+
+ protected override string ResolveBranchName(VersionContext context)
+ {
+ return context.Result.CanonicalBranchName.Substring(context.Result.CanonicalBranchName.LastIndexOf('/') + 1);
+ }
+ }
}
diff --git a/src/SimpleVersion.Core/Rules/HeightRule.cs b/src/SimpleVersion.Core/Rules/HeightRule.cs
index f313369..b38fc97 100644
--- a/src/SimpleVersion.Core/Rules/HeightRule.cs
+++ b/src/SimpleVersion.Core/Rules/HeightRule.cs
@@ -1,4 +1,4 @@
-// Licensed under the MIT license. See https://kieranties.mit-license.org/ for full license information.
+// Licensed under the MIT license. See https://kieranties.mit-license.org/ for full license information.
using SimpleVersion.Pipeline;
using System;
@@ -7,44 +7,44 @@
namespace SimpleVersion.Rules
{
- public class HeightRule : IRule
- {
- private static Lazy _default = new Lazy(() => new HeightRule());
-
- public static HeightRule Instance => _default.Value;
-
- public HeightRule() :this(false)
- {
-
- }
-
- public HeightRule(bool padded)
- {
- Padded = padded;
- }
-
- public bool Padded { get; }
-
- public string Token => "*";
-
- public string Resolve(VersionContext context, string value)
- {
- if (Padded)
- return value.Replace(Token, context.Result.HeightPadded);
- else
- return value.Replace(Token, context.Result.Height.ToString(System.Globalization.CultureInfo.CurrentCulture));
- }
-
- public IEnumerable Apply(VersionContext context, IEnumerable input)
- {
- if (!context.Configuration.Version.Contains(Token)
- && input.Count() != 0
- && !input.Contains(Token))
- {
- return input.Concat(new[] { Token });
- }
-
- return input;
- }
- }
+ public class HeightRule : IRule
+ {
+ private static readonly Lazy _default = new Lazy(() => new HeightRule());
+
+ public static HeightRule Instance => _default.Value;
+
+ public HeightRule() : this(false)
+ {
+
+ }
+
+ public HeightRule(bool padded)
+ {
+ Padded = padded;
+ }
+
+ public bool Padded { get; }
+
+ public string Token => "*";
+
+ public string Resolve(VersionContext context, string value)
+ {
+ if (Padded)
+ return value.Replace(Token, context.Result.HeightPadded);
+ else
+ return value.Replace(Token, context.Result.Height.ToString(System.Globalization.CultureInfo.CurrentCulture));
+ }
+
+ public IEnumerable Apply(VersionContext context, IEnumerable input)
+ {
+ if (!context.Configuration.Version.Contains(Token)
+ && input.Count() != 0
+ && !input.Contains(Token))
+ {
+ return input.Concat(new[] { Token });
+ }
+
+ return input;
+ }
+ }
}
diff --git a/src/SimpleVersion.Core/Rules/RuleExtensions.cs b/src/SimpleVersion.Core/Rules/RuleExtensions.cs
index 4ec8612..5cbe510 100644
--- a/src/SimpleVersion.Core/Rules/RuleExtensions.cs
+++ b/src/SimpleVersion.Core/Rules/RuleExtensions.cs
@@ -1,28 +1,28 @@
-// Licensed under the MIT license. See https://kieranties.mit-license.org/ for full license information.
+// Licensed under the MIT license. See https://kieranties.mit-license.org/ for full license information.
using SimpleVersion.Pipeline;
using System.Collections.Generic;
namespace SimpleVersion.Rules
{
- public static class RuleExtensions
- {
- public static IEnumerable ApplyRules(this IEnumerable value, VersionContext context, IEnumerable> rules)
- {
- var next = value;
- foreach (var rule in rules)
- next = rule.Apply(context, next);
+ public static class RuleExtensions
+ {
+ public static IEnumerable ApplyRules(this IEnumerable value, VersionContext context, IEnumerable> rules)
+ {
+ var next = value;
+ foreach (var rule in rules)
+ next = rule.Apply(context, next);
- return next;
- }
+ return next;
+ }
- public static T ResolveRules(this T value, VersionContext context, IEnumerable> rules)
- {
- var next = value;
- foreach (var rule in rules)
- next = rule.Resolve(context, next);
+ public static T ResolveRules(this T value, VersionContext context, IEnumerable> rules)
+ {
+ var next = value;
+ foreach (var rule in rules)
+ next = rule.Resolve(context, next);
- return next;
- }
- }
+ return next;
+ }
+ }
}
diff --git a/src/SimpleVersion.Core/Rules/ShortBranchNameRule.cs b/src/SimpleVersion.Core/Rules/ShortBranchNameRule.cs
index 80b1255..d819ba9 100644
--- a/src/SimpleVersion.Core/Rules/ShortBranchNameRule.cs
+++ b/src/SimpleVersion.Core/Rules/ShortBranchNameRule.cs
@@ -1,26 +1,26 @@
-// Licensed under the MIT license. See https://kieranties.mit-license.org/ for full license information.
+// Licensed under the MIT license. See https://kieranties.mit-license.org/ for full license information.
using SimpleVersion.Pipeline;
using System;
namespace SimpleVersion.Rules
{
- public class ShortBranchNameRule : BaseBranchNameRule
- {
- private static Lazy _default = new Lazy(() => new ShortBranchNameRule());
+ public class ShortBranchNameRule : BaseBranchNameRule
+ {
+ private static readonly Lazy _default = new Lazy(() => new ShortBranchNameRule());
- public static ShortBranchNameRule Instance => _default.Value;
+ public static ShortBranchNameRule Instance => _default.Value;
- public ShortBranchNameRule() : base()
- {
- }
+ public ShortBranchNameRule() : base()
+ {
+ }
- public ShortBranchNameRule(string pattern) : base(pattern)
- {
- }
-
- public override string Token { get; protected set; } = "{shortbranchname}";
+ public ShortBranchNameRule(string pattern) : base(pattern)
+ {
+ }
- protected override string ResolveBranchName(VersionContext context) => context.Result.BranchName;
- }
+ public override string Token { get; protected set; } = "{shortbranchname}";
+
+ protected override string ResolveBranchName(VersionContext context) => context.Result.BranchName;
+ }
}
diff --git a/src/SimpleVersion.Core/Rules/ShortShaRule.cs b/src/SimpleVersion.Core/Rules/ShortShaRule.cs
index fa4db81..b49dae1 100644
--- a/src/SimpleVersion.Core/Rules/ShortShaRule.cs
+++ b/src/SimpleVersion.Core/Rules/ShortShaRule.cs
@@ -1,4 +1,4 @@
-// Licensed under the MIT license. See https://kieranties.mit-license.org/ for full license information.
+// Licensed under the MIT license. See https://kieranties.mit-license.org/ for full license information.
using SimpleVersion.Pipeline;
using System;
@@ -8,31 +8,31 @@
namespace SimpleVersion.Rules
{
- public class ShortShaRule : IRule
- {
- private static Lazy _default = new Lazy(() => new ShortShaRule());
+ public class ShortShaRule : IRule
+ {
+ private static readonly Lazy _default = new Lazy(() => new ShortShaRule());
- public static ShortShaRule Instance => _default.Value;
+ public static ShortShaRule Instance => _default.Value;
- public string Token => "{shortsha}";
+ public string Token => "{shortsha}";
- public string Resolve(VersionContext context, string value)
- {
- var shortSha = context.Result.Sha.Substring(0, 7);
- return Regex.Replace(value, Regex.Escape(Token), $"c{shortSha}", RegexOptions.IgnoreCase);
- }
+ public string Resolve(VersionContext context, string value)
+ {
+ var shortSha = context.Result.Sha.Substring(0, 7);
+ return Regex.Replace(value, Regex.Escape(Token), $"c{shortSha}", RegexOptions.IgnoreCase);
+ }
- public IEnumerable Apply(VersionContext context, IEnumerable input)
- {
- var isRelease = context.Configuration.Branches.Release
- .Any(x => Regex.IsMatch(context.Result.CanonicalBranchName, x));
+ public IEnumerable Apply(VersionContext context, IEnumerable input)
+ {
+ var isRelease = context.Configuration.Branches.Release
+ .Any(x => Regex.IsMatch(context.Result.CanonicalBranchName, x));
- if (!isRelease && !input.Contains(Token))
- {
- return input.Concat(new[] { Token });
- }
+ if (!isRelease && !input.Contains(Token))
+ {
+ return input.Concat(new[] { Token });
+ }
- return input;
- }
- }
+ return input;
+ }
+ }
}
diff --git a/src/SimpleVersion.Core/SimpleVersion.Core.csproj b/src/SimpleVersion.Core/SimpleVersion.Core.csproj
index ff146bc..d48cc9f 100644
--- a/src/SimpleVersion.Core/SimpleVersion.Core.csproj
+++ b/src/SimpleVersion.Core/SimpleVersion.Core.csproj
@@ -1,18 +1,18 @@
-
-
+
+
-
- SimpleVersion
-
+
+ SimpleVersion
+
-
-
-
-
-
+
+
+
+
+
-
-
-
+
+
+
diff --git a/src/SimpleVersion.Core/StringExtensions.cs b/src/SimpleVersion.Core/StringExtensions.cs
index f78a02c..d16fe87 100644
--- a/src/SimpleVersion.Core/StringExtensions.cs
+++ b/src/SimpleVersion.Core/StringExtensions.cs
@@ -1,22 +1,22 @@
-// Licensed under the MIT license. See https://kieranties.mit-license.org/ for full license information.
+// Licensed under the MIT license. See https://kieranties.mit-license.org/ for full license information.
using System;
namespace SimpleVersion
{
- public static class StringExtensions
- {
- public static bool ToBool(this string value)
- {
- if (string.IsNullOrWhiteSpace(value))
- return false;
+ public static class StringExtensions
+ {
+ public static bool ToBool(this string value)
+ {
+ if (string.IsNullOrWhiteSpace(value))
+ return false;
- if(int.TryParse(value, out var intValue))
- {
- return intValue == 0;
- }
+ if (int.TryParse(value, out var intValue))
+ {
+ return intValue == 0;
+ }
- return bool.TrueString.Equals(value, StringComparison.OrdinalIgnoreCase);
- }
- }
+ return bool.TrueString.Equals(value, StringComparison.OrdinalIgnoreCase);
+ }
+ }
}
diff --git a/src/SimpleVersion.Core/VersioningEnvironment.cs b/src/SimpleVersion.Core/VersioningEnvironment.cs
index 6a62f69..417f995 100644
--- a/src/SimpleVersion.Core/VersioningEnvironment.cs
+++ b/src/SimpleVersion.Core/VersioningEnvironment.cs
@@ -1,9 +1,9 @@
-// Licensed under the MIT license. See https://kieranties.mit-license.org/ for full license information.
+// Licensed under the MIT license. See https://kieranties.mit-license.org/ for full license information.
namespace SimpleVersion
{
- public class VersioningEnvironment : IEnvironment
- {
- public string GetVariable(string name) => System.Environment.GetEnvironmentVariable(name);
- }
+ public class VersioningEnvironment : IEnvironment
+ {
+ public string GetVariable(string name) => System.Environment.GetEnvironmentVariable(name);
+ }
}
diff --git a/test/Assets/.simpleversion.json b/test/Assets/.simpleversion.json
index 87f4532..136efee 100644
--- a/test/Assets/.simpleversion.json
+++ b/test/Assets/.simpleversion.json
@@ -1,12 +1,12 @@
{
- "Version": "1.2.3.4",
- "Label": [ "alpha1" ],
- "Metadata": [ "test", "branch" ],
- "Branches": {
- "Release": [
- "^master$",
- "^preview/.+$",
- "^release/.+$"
- ]
- }
-}
\ No newline at end of file
+ "Version": "1.2.3.4",
+ "Label": [ "alpha1" ],
+ "Metadata": [ "test", "branch" ],
+ "Branches": {
+ "Release": [
+ "^master$",
+ "^preview/.+$",
+ "^release/.+$"
+ ]
+ }
+}
diff --git a/test/Assets/Expectations/Empty.json b/test/Assets/Expectations/Empty.json
index 7ce1cb1..7e0e312 100644
--- a/test/Assets/Expectations/Empty.json
+++ b/test/Assets/Expectations/Empty.json
@@ -1,9 +1,9 @@
{
- "Version": "",
- "OffSet": 0,
- "Label": [],
- "MetaData": [],
- "Branches": {
- "Release": []
- }
-}
\ No newline at end of file
+ "Version": "",
+ "OffSet": 0,
+ "Label": [],
+ "MetaData": [],
+ "Branches": {
+ "Release": []
+ }
+}
diff --git a/test/Assets/Expectations/ToTextWithModel.json b/test/Assets/Expectations/ToTextWithModel.json
index 6cd8827..372f0ea 100644
--- a/test/Assets/Expectations/ToTextWithModel.json
+++ b/test/Assets/Expectations/ToTextWithModel.json
@@ -1,15 +1,15 @@
{
- "Version": "1.2.3.4",
- "OffSet": 0,
- "Label": [
- "First",
- "Second"
- ],
- "MetaData": [
- "Meta1",
- "Meta2"
- ],
- "Branches": {
- "Release": []
- }
-}
\ No newline at end of file
+ "Version": "1.2.3.4",
+ "OffSet": 0,
+ "Label": [
+ "First",
+ "Second"
+ ],
+ "MetaData": [
+ "Meta1",
+ "Meta2"
+ ],
+ "Branches": {
+ "Release": []
+ }
+}
diff --git a/test/Directory.Build.props b/test/Directory.Build.props
index f2512ba..2d7fbff 100644
--- a/test/Directory.Build.props
+++ b/test/Directory.Build.props
@@ -1,30 +1,30 @@
-
-
-
- false
-
+
-
-
-
-
-
-
-
+
+ false
+
+
+
+
+
+
+
+
+
+
+
+
+ Assets\%(RecursiveDir)%(Filename)%(Extension)
+ Always
+
+
+
+
+
+ GlobalSuppressions.cs
+
+
-
-
- Assets\%(RecursiveDir)%(Filename)%(Extension)
- Always
-
-
-
-
-
- GlobalSuppressions.cs
-
-
-
diff --git a/test/SimpleVersion.Abstractions.Tests/Model/BranchConfigurationFixture.cs b/test/SimpleVersion.Abstractions.Tests/Model/BranchConfigurationFixture.cs
index 380348f..fe56171 100644
--- a/test/SimpleVersion.Abstractions.Tests/Model/BranchConfigurationFixture.cs
+++ b/test/SimpleVersion.Abstractions.Tests/Model/BranchConfigurationFixture.cs
@@ -1,4 +1,4 @@
-// Licensed under the MIT license. See https://kieranties.mit-license.org/ for full license information.
+// Licensed under the MIT license. See https://kieranties.mit-license.org/ for full license information.
using FluentAssertions;
using SimpleVersion.Model;
@@ -6,18 +6,18 @@
namespace SimpleVersion.Abstractions.Tests.Model
{
- public class BranchConfigurationFixture
- {
- [Fact]
- public void Ctor_SetsDefaults()
- {
- // Arrange / Act
- var sut = new BranchConfiguration();
+ public class BranchConfigurationFixture
+ {
+ [Fact]
+ public void Ctor_SetsDefaults()
+ {
+ // Arrange / Act
+ var sut = new BranchConfiguration();
- // Assert
- sut.Label.Should().BeNull();
- sut.Match.Should().BeEmpty();
- sut.MetaData.Should().BeNull();
- }
- }
+ // Assert
+ sut.Label.Should().BeNull();
+ sut.Match.Should().BeEmpty();
+ sut.MetaData.Should().BeNull();
+ }
+ }
}
diff --git a/test/SimpleVersion.Abstractions.Tests/Model/BranchInfoFixture.cs b/test/SimpleVersion.Abstractions.Tests/Model/BranchInfoFixture.cs
index da7ed79..f8559db 100644
--- a/test/SimpleVersion.Abstractions.Tests/Model/BranchInfoFixture.cs
+++ b/test/SimpleVersion.Abstractions.Tests/Model/BranchInfoFixture.cs
@@ -1,4 +1,4 @@
-// Licensed under the MIT license. See https://kieranties.mit-license.org/ for full license information.
+// Licensed under the MIT license. See https://kieranties.mit-license.org/ for full license information.
using FluentAssertions;
using SimpleVersion.Model;
@@ -6,17 +6,17 @@
namespace SimpleVersion.Abstractions.Tests.Model
{
- public class BranchInfoFixture
- {
- [Fact]
- public void Ctor_PopulatesEmpty_Release()
- {
- // Arrange / Act
- var sut = new BranchInfo();
+ public class BranchInfoFixture
+ {
+ [Fact]
+ public void Ctor_PopulatesEmpty_Release()
+ {
+ // Arrange / Act
+ var sut = new BranchInfo();
- // Assert
- sut.Release.Should().BeEmpty();
- sut.Overrides.Should().BeEmpty();
- }
- }
+ // Assert
+ sut.Release.Should().BeEmpty();
+ sut.Overrides.Should().BeEmpty();
+ }
+ }
}
diff --git a/test/SimpleVersion.Abstractions.Tests/Model/ConfigurationFixture.cs b/test/SimpleVersion.Abstractions.Tests/Model/ConfigurationFixture.cs
index 42fae5c..148aa21 100644
--- a/test/SimpleVersion.Abstractions.Tests/Model/ConfigurationFixture.cs
+++ b/test/SimpleVersion.Abstractions.Tests/Model/ConfigurationFixture.cs
@@ -1,4 +1,4 @@
-// Licensed under the MIT license. See https://kieranties.mit-license.org/ for full license information.
+// Licensed under the MIT license. See https://kieranties.mit-license.org/ for full license information.
using FluentAssertions;
using SimpleVersion.Model;
@@ -7,53 +7,53 @@
namespace SimpleVersion.Abstractions.Tests.Model
{
- public class ConfigurationFixture
- {
- [Fact]
- public void Ctor_SetsDefaults()
- {
- // Arrange / Act
- var sut = new Configuration();
-
- // Assert
- sut.Label.Should().BeEmpty();
- sut.MetaData.Should().BeEmpty();
- sut.Version.Should().BeEmpty();
- sut.OffSet.Should().Be(0);
- sut.Branches.Should().NotBeNull();
- }
-
- [Fact]
- public void Equals_GivenNull_ReturnsFalse()
- {
- // Arrange
- var sut = new Configuration();
-
- // Act
- var result = sut.Equals(null);
-
- // Assert
- result.Should().BeFalse();
- }
-
- public static string Thing => "this";
-
- public static IEnumerable