Skip to content

Commit

Permalink
feat: Adding documentation for simple caret with no minor
Browse files Browse the repository at this point in the history
Signed-off-by: Vincent Boutour <[email protected]>
  • Loading branch information
ViBiOh committed May 22, 2021
1 parent 2091d6b commit bfcf0b8
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 7 deletions.
8 changes: 4 additions & 4 deletions cmd/ketchup/templates/ketchup.html
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ <h2 class="header">Create ketchup</h2>
<p class="padding no-margin">
<label for="create-pattern" class="block">Pattern: <img class="icon icon-small" title="'latest': latest version, beta included.
'stable': latest version without beta.
'^1.0': latest with fixed major version.
'^1': latest with fixed major version.
'~1.1': latest with fixed major and minor version.
'^1.0-0': include beta (works also for '~')." src="{{ url "/svg/question?fill=silver" }}" alt="question icon"></label>
'^1-0': include beta (works also for '~')." src="{{ url "/svg/question?fill=silver" }}" alt="question icon"></label>
<input id="create-pattern" type="text" name="pattern" placeholder="stable" class="full">
</p>

Expand Down Expand Up @@ -112,9 +112,9 @@ <h2 class="header">Edit ketchup</h2>
<p class="padding no-margin">
<label for="edit-pattern-{{ .Repository.ID }}" class="block">Pattern: <img class="icon icon-small" title="'latest': latest version, beta included.
'stable': latest version without beta.
'^1.0': latest with fixed major version.
'^1': latest with fixed major version.
'~1.1': latest with fixed major and minor version.
'^1.0-0': include beta (works also for '~')." src="{{ url "/svg/question?fill=silver" }}" alt="question icon"></label>
'^1-0': include beta (works also for '~')." src="{{ url "/svg/question?fill=silver" }}" alt="question icon"></label>
<input id="edit-pattern-{{ .Repository.ID }}" name="pattern" type="text" value="{{ .Pattern }}">
</p>

Expand Down
2 changes: 1 addition & 1 deletion pkg/semver/pattern.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func (p Pattern) Check(version Version) bool {

// ParsePattern parse given constraint to extract pattern matcher
func ParsePattern(pattern string) (Pattern, error) {
if len(pattern) < 4 {
if len(pattern) < 2 {
return NonePattern, errors.New("pattern is invalid")
}

Expand Down
20 changes: 18 additions & 2 deletions pkg/semver/pattern_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func TestCheck(t *testing.T) {
}{
{
"too short",
safeParsePattern("tst"),
safeParsePattern("1"),
args{
version: safeParse(stableVersion),
},
Expand Down Expand Up @@ -69,6 +69,22 @@ func TestCheck(t *testing.T) {
},
false,
},
{
"simple caret",
safeParsePattern("^2"),
args{
version: safeParse(stableVersion),
},
false,
},
{
"simple caret match",
safeParsePattern("^1"),
args{
version: safeParse(stableVersion),
},
true,
},
{
"caret",
safeParsePattern("^1.0"),
Expand Down Expand Up @@ -111,7 +127,7 @@ func TestCheck(t *testing.T) {
},
{
"caret beta",
safeParsePattern("^1.1.0-0"),
safeParsePattern("^1-0"),
args{
version: safeParse("1.1.0-beta1"),
},
Expand Down

0 comments on commit bfcf0b8

Please sign in to comment.