-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
bug: Use * as part of a label string
Fixes #61 (cherry picked from commit 1c6a52a) # Conflicts: # src/SimpleVersion.Core/Rules/HeightRule.cs # test/SimpleVersion.Core.Tests/Pipeline/Formatting/Semver2FormatProcessFixture.cs
- Loading branch information
1 parent
9c548f4
commit 19f4a56
Showing
3 changed files
with
74 additions
and
26 deletions.
There are no files selected for viewing
This file contains 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,48 @@ | ||
using SimpleVersion.Pipeline; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
|
||
namespace SimpleVersion.Rules | ||
{ | ||
public class HeightRule : IRule<string> | ||
{ | ||
private static Lazy<HeightRule> _default = new Lazy<HeightRule>(() => 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()); | ||
} | ||
|
||
public IEnumerable<string> Apply(VersionContext context, IEnumerable<string> input) | ||
{ | ||
if (!context.Configuration.Version.Contains(Token) | ||
&& input.Count() != 0 | ||
&& !input.Any(x => x.Contains(Token))) | ||
{ | ||
return input.Concat(new[] { Token }); | ||
} | ||
|
||
return input; | ||
} | ||
} | ||
} |
This file contains 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 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